refactor: add rules

This commit is contained in:
Thanaphon Frappet 2024-10-15 11:14:30 +07:00
parent 1fb2606885
commit 132f533fd0
2 changed files with 18 additions and 3 deletions

View file

@ -382,7 +382,11 @@ watch(
class="col"
label="Name"
v-model="firstNameEN"
:rules="[(val: string) => !!val || $t('form.error.required')]"
:rules="[
(val: string) => !!val || $t('form.error.required'),
(val: string) =>
/^[A-Za-z]+$/.test(val) || $t('form.error.letterOnly'),
]"
/>
<q-input
:for="`${prefixId}-input-last-name`"
@ -393,7 +397,11 @@ watch(
class="col"
label="Surname"
v-model="lastNameEN"
:rules="[(val: string) => !!val || $t('form.error.required')]"
:rules="[
(val: string) => !!val || $t('form.error.required'),
(val: string) =>
/^[A-Za-z]+$/.test(val) || $t('form.error.letterOnly'),
]"
/>
</div>