refactor: handle input rules

This commit is contained in:
Thanaphon Frappet 2024-11-29 13:57:19 +07:00
parent 9fa735c529
commit 0d72c5eee6
2 changed files with 39 additions and 0 deletions

View file

@ -263,6 +263,9 @@ watch(
(v) => (typeof v === 'string' ? (workerStatus = v) : '') (v) => (typeof v === 'string' ? (workerStatus = v) : '')
" "
@clear="workerStatus = ''" @clear="workerStatus = ''"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
> >
<template v-slot:no-option> <template v-slot:no-option>
<q-item> <q-item>
@ -384,6 +387,9 @@ watch(
@update:model-value=" @update:model-value="
(v) => (typeof v === 'string' ? (firstNameEN = v.trim()) : '') (v) => (typeof v === 'string' ? (firstNameEN = v.trim()) : '')
" "
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/> />
<q-input <q-input
@ -412,6 +418,9 @@ watch(
@update:model-value=" @update:model-value="
(v) => (typeof v === 'string' ? (lastNameEN = v.trim()) : '') (v) => (typeof v === 'string' ? (lastNameEN = v.trim()) : '')
" "
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/> />
<q-input <q-input
@ -530,6 +539,9 @@ watch(
typeof v === 'string' ? (birthCountry = nationality = v) : '' typeof v === 'string' ? (birthCountry = nationality = v) : ''
" "
@clear="nationality = ''" @clear="nationality = ''"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
> >
<template v-slot:no-option> <template v-slot:no-option>
<q-item> <q-item>

View file

@ -188,6 +188,9 @@ watch(
(v) => (typeof v === 'string' ? (workerType = v) : '') (v) => (typeof v === 'string' ? (workerType = v) : '')
" "
@clear="workerType = ''" @clear="workerType = ''"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
> >
<template v-slot:no-option> <template v-slot:no-option>
<q-item> <q-item>
@ -224,6 +227,9 @@ watch(
@update:model-value=" @update:model-value="
(v) => (typeof v === 'string' ? (issuePlace = v) : '') (v) => (typeof v === 'string' ? (issuePlace = v) : '')
" "
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/> />
<q-select <q-select
@ -314,6 +320,9 @@ watch(
} }
} }
" "
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
clearable clearable
/> />
</div> </div>
@ -330,6 +339,9 @@ watch(
((issueDate && new Date(issueDate).getTime()) || Date.now()) ((issueDate && new Date(issueDate).getTime()) || Date.now())
" "
clearable clearable
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/> />
</div> </div>
<div class="col"> <div class="col">
@ -356,6 +368,9 @@ watch(
@update:model-value=" @update:model-value="
(v) => (typeof v === 'string' ? (arrivalTMNo = v) : '') (v) => (typeof v === 'string' ? (arrivalTMNo = v) : '')
" "
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/> />
<DatePicker <DatePicker
@ -365,6 +380,9 @@ watch(
:label="$t('customerEmployee.form.visaEnter')" :label="$t('customerEmployee.form.visaEnter')"
v-model="arrivalTM" v-model="arrivalTM"
clearable clearable
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/> />
<q-input <q-input
@ -379,6 +397,9 @@ watch(
@update:model-value=" @update:model-value="
(v) => (typeof v === 'string' ? (arrivalAt = v) : '') (v) => (typeof v === 'string' ? (arrivalAt = v) : '')
" "
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/> />
<q-select <q-select
@ -406,6 +427,9 @@ watch(
(v) => (typeof v === 'string' ? (issueCountry = v) : '') (v) => (typeof v === 'string' ? (issueCountry = v) : '')
" "
@clear="type = ''" @clear="type = ''"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
> >
<template v-slot:no-option> <template v-slot:no-option>
<q-item> <q-item>
@ -427,6 +451,9 @@ watch(
v-model="entryCount" v-model="entryCount"
type="number" type="number"
min="0" min="0"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/> />
</div> </div>
</div> </div>