feat: VnInput numberValidation
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-05-06 07:24:52 +02:00
parent d15a92ce7d
commit 0f5d06614d
1 changed files with 14 additions and 0 deletions

View File

@ -52,6 +52,12 @@ const focus = () => {
defineExpose({
focus,
});
const inputRules = (val) => {
const { min } = vnInputRef.value.$attrs;
if (min >= 0)
if (val.toString().indexOf('.') < min) return t('inputMin', { value: min });
};
</script>
<template>
@ -68,6 +74,8 @@ defineExpose({
:class="{ required: $attrs.required }"
@keyup.enter="onEnterPress()"
:clearable="false"
:rules="[inputRules]"
:lazy-rules="true"
>
<template v-if="$slots.prepend" #prepend>
<slot name="prepend" />
@ -85,3 +93,9 @@ defineExpose({
</QInput>
</div>
</template>
<i18n>
en:
inputMin: Must be more than {value}
es:
inputMin: Debe ser mayor a {value}
</i18n>