refactor: handle nrcNO not required

This commit is contained in:
Thanaphon Frappet 2024-10-28 19:55:39 +07:00
parent 5f6cdf2fce
commit d072ed015a

View file

@ -297,11 +297,12 @@ defineEmits<{
:readonly="readonly" :readonly="readonly"
class="col-6" class="col-6"
:label="$t('customerEmployee.form.nrcNo')" :label="$t('customerEmployee.form.nrcNo')"
:model-value="readonly ? nrcNo || '-' : nrcNo" :model-value="nrcNo"
@update:model-value="(v) => (typeof v === 'string' ? (nrcNo = v) : '')" @update:model-value="(v) => (typeof v === 'string' ? (nrcNo = v) : '')"
:rules="[ :rules="[
(val) => (val) =>
(val && val.length === 13 && /[0-9]+/.test(val)) || !val ||
val.length === 13 ||
$t('form.error.invalidCustomeMessage', { $t('form.error.invalidCustomeMessage', {
msg: $t('form.error.requireLength', { msg: 13 }), msg: $t('form.error.requireLength', { msg: 13 }),
}), }),