fix: enhance validation rules for agency and employer name fields
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s

This commit is contained in:
puriphatt 2025-05-23 11:40:22 +07:00
parent de281ea79f
commit 0916ce7af2
2 changed files with 25 additions and 6 deletions

View file

@ -68,7 +68,12 @@ type Options = { label: string; value: string };
class="col-md-4 col-12"
:label="$t('agencies.name')"
v-model="name"
:rules="[(val: string) => !!val || $t('form.error.required')]"
:rules="[
(val) => !!val || $t('form.error.required'),
(val) =>
/^[A-Za-z0-9ก-๙\s&.,'-]+$/.test(val) ||
$t('form.error.branchNameField'),
]"
/>
<q-input
for="input-agencies-name-en"
@ -79,6 +84,15 @@ type Options = { label: string; value: string };
class="col-md-4 col-12"
:label="'Agencies Name'"
v-model="nameEn"
:rules="
nameEn
? [
(val) =>
/^[A-Za-z0-9ก-๙\s&.,'-]+$/.test(val) ||
$t('form.error.branchNameENField'),
]
: []
"
/>
<q-input

View file

@ -137,7 +137,12 @@ watch(
@update:model-value="
(v) => (typeof v === 'string' ? (registerName = v.trim()) : '')
"
:rules="[(val: string) => !!val || $t('form.error.required')]"
:rules="[
(val) => !!val || $t('form.error.required'),
(val) =>
/^[A-Za-z0-9ก-๙\s&.,'-]+$/.test(val) ||
$t('form.error.branchNameField'),
]"
/>
<q-input
@ -153,10 +158,10 @@ watch(
(v) => (typeof v === 'string' ? (registerNameEN = v.trim()) : '')
"
:rules="[
(val: string) =>
val === '' ||
/^[0-9A-Za-z\s.,]+$/.test(val) ||
$t('form.error.letterOnly'),
(val) => !!val || $t('form.error.required'),
(val) =>
/^[A-Za-z0-9\s&.,'-]+$/.test(val) ||
$t('form.error.branchNameENField'),
]"
/>
</div>