From ccbfe7e0d93d98f83fb76cdec5984435c7a138c4 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 21 Jun 2024 15:04:38 +0200 Subject: [PATCH] updates --- src/components/common/VnInput.vue | 5 ++++- src/components/common/VnSelect.vue | 15 +++++++++++---- src/composables/useValidator.js | 9 ++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/components/common/VnInput.vue b/src/components/common/VnInput.vue index 711e0d90a..5df3b7a11 100644 --- a/src/components/common/VnInput.vue +++ b/src/components/common/VnInput.vue @@ -25,6 +25,7 @@ const $props = defineProps({ }); const { t } = useI18n(); +const requiredFieldRule = (val) => !!val || t('globals.fieldRequired'); const vnInputRef = ref(null); const value = computed({ get() { @@ -53,7 +54,8 @@ defineExpose({ focus, }); -const inputRules = [ +const mixinRules = [ + requiredFieldRule, (val) => { const { min } = vnInputRef.value.$attrs; if (min >= 0) if (Math.floor(val) < min) return t('inputMin', { value: min }); @@ -71,6 +73,7 @@ const inputRules = [ :class="{ required: $attrs.required }" @keyup.enter="emit('keyup.enter')" :clearable="false" + :rules="$attrs.required || $attrs.min ? mixinRules : null" :lazy-rules="true" hide-bottom-space > diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index 12d110170..1ee6930eb 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -1,10 +1,10 @@