feat: Regulären Ausdruck zur Überprüfung der Stadt im Frontend hinzugefügt.

This commit is contained in:
Developer 02 2024-07-18 14:13:33 +02:00
parent fe1d553a8d
commit 7d582d2422
3 changed files with 43 additions and 1 deletions

View File

@ -119,5 +119,17 @@
"AddedWho": "DDEnvelopGenerator",
"ReminderTypeId": 202377,
"EmailAttmt1": ""
}
},
"Regexes": [
{
"Pattern": "/^\\p{L}+(?:([\\ \\-\\']|(\\.\\ ))\\p{L}+)*$/u",
"Name": "City",
"Platforms": [ ".NET" ]
},
{
"Pattern": "/^[a-zA-Z\\u0080-\\u024F]+(?:([\\ \\-\\']|(\\.\\ ))[a-zA-Z\\u0080-\\u024F]+)*$/",
"Name": "City",
"Platforms": [ "javascript" ]
}
]
}

View File

@ -108,6 +108,8 @@
this.markFieldAsRequired(formFieldCity);
this.markFieldAsCity(formFieldCity);
/**
* Date, post code and place label part
*/
@ -307,6 +309,7 @@
return inch * 72
}
//required
static #requiredFieldNames = new Array()
static markFieldAsRequired(formField) {
@ -316,4 +319,15 @@
static isFieldRequired(formField) {
return this.#requiredFieldNames.includes(formField.name)
}
//city
static #cityFieldNames = new Array()
static markFieldAsCity(formField) {
this.#cityFieldNames.push(formField.name)
}
static isCityField(formField){
return this.#cityFieldNames.includes(formField.name)
}
}

View File

@ -170,6 +170,8 @@ class App {
async handleFinish(event) {
const iJSON = await this.Instance.exportInstantJSON()
const iFormFieldValues = await iJSON.formFieldValues;
//check required
const iReqFields = iFormFieldValues.filter(f => Annotation.isFieldRequired(f))
const hasEmptyReq = iReqFields.some(f => (f.value === undefined || f.value === null || f.value === ""))
@ -182,6 +184,20 @@ class App {
return false;
}
//check city
const city_regex = new RegExp("^[a-zA-Z\\u0080-\\u024F]+(?:([\\ \\-\\']|(\\.\\ ))[a-zA-Z\\u0080-\\u024F]+)*$")
const iCityFields = iFormFieldValues.filter(f => Annotation.isCityField(f))
for(var f of iCityFields)
if(!city_regex.test(f.value)){
Swal.fire({
title: 'Warnung',
text: `Bitte überprüfen Sie die eingegebene Ortsangabe "${f.value}" auf korrekte Formatierung. Beispiele für richtige Formate sind: München, Île-de-France, Sauðárkrókur, San Francisco, St. Catharines usw.`,
icon: 'warning',
})
return false;
}
//check # of signature
const validationResult = await this.validateAnnotations(this.signatureCount)
if (validationResult === false) {
Swal.fire({