Merged in feature/VBV-751-kaufprozess-validierung-in-plz (pull request #406)
PLZ validieren im Onboarding Approved-by: Christian Cueni
This commit is contained in:
commit
dc572ad1a3
|
|
@ -219,6 +219,7 @@
|
|||
"a.Personen, die du begleitest": "Personen, die du begleitest ",
|
||||
"a.Persönliche Informationen": "Persönliche Informationen",
|
||||
"a.PLZ": "PLZ",
|
||||
"a.Postleizahl hat das falsche Format": "Postleizahl hat das falsche Format",
|
||||
"a.Praxisauftrag": "Praxisauftrag",
|
||||
"a.Praxisaufträge anschauen": "Praxisaufträge anschauen",
|
||||
"a.Praxisbildner": "Praxisbildner",
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@
|
|||
"a.Personen, die du begleitest": "Personnes que tu accompagnes",
|
||||
"a.Persönliche Informationen": "Informations personnelles",
|
||||
"a.PLZ": "Code postal",
|
||||
"a.Postleizahl hat das falsche Format": "Le code postal n'a pas le bon format",
|
||||
"a.Praxisauftrag": "Exercice pratique",
|
||||
"a.Praxisaufträge anschauen": "Voir les missions pratiques",
|
||||
"a.Praxisbildner": "Formateur pratique",
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@
|
|||
"a.Personen, die du begleitest": "Persone che accompagni",
|
||||
"a.Persönliche Informationen": "Informazioni personali",
|
||||
"a.PLZ": "CAP",
|
||||
"a.Postleizahl hat das falsche Format": "Il codice postale ha un formato sbagliato",
|
||||
"a.Praxisauftrag": "Lavoro pratico",
|
||||
"a.Praxisaufträge anschauen": "Visualizzare gli incarichi pratici",
|
||||
"a.Praxisbildner": "Formatore pratico",
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { useEntities } from "@/services/entities";
|
|||
import { getLocalSessionKey } from "@/statistics";
|
||||
import { type User, useUserStore } from "@/stores/user";
|
||||
import { normalizeSwissPhoneNumber, validatePhoneNumber } from "@/utils/phone";
|
||||
import { validatePostalCode } from "@/utils/postalcode";
|
||||
import { useTranslation } from "i18next-vue";
|
||||
import log from "loglevel";
|
||||
import { computed, ref, watch } from "vue";
|
||||
|
|
@ -129,6 +130,8 @@ function validateAddress() {
|
|||
|
||||
if (!address.value.postal_code) {
|
||||
formErrors.value.personal.push(t("a.PLZ"));
|
||||
} else if (!validatePostalCode(address.value.postal_code)) {
|
||||
formErrors.value.personal.push(t("a.Postleizahl hat das falsche Format"));
|
||||
}
|
||||
|
||||
if (!address.value.city) {
|
||||
|
|
@ -172,6 +175,8 @@ function validateAddress() {
|
|||
|
||||
if (!address.value.organisation_postal_code) {
|
||||
formErrors.value.company.push(t("a.PLZ"));
|
||||
} else if (!validatePostalCode(address.value.organisation_postal_code)) {
|
||||
formErrors.value.personal.push(t("a.Postleizahl hat das falsche Format"));
|
||||
}
|
||||
|
||||
if (!address.value.organisation_city) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
export function validatePostalCode(input: string) {
|
||||
// Remove non-ASCII characters
|
||||
// eslint-disable-next-line no-control-regex
|
||||
input = input.replace(/[^\x00-\x7F]/g, "");
|
||||
if (input.length < 4) {
|
||||
return false;
|
||||
}
|
||||
const regex = /^[0-9]+$/;
|
||||
return regex.test(input);
|
||||
}
|
||||
Loading…
Reference in New Issue