0
0
Fork 0

fix: useRequired composable

This commit is contained in:
Javier Segarra 2024-11-29 22:45:32 +01:00
parent d9d6819390
commit 37e557264c
1 changed files with 8 additions and 2 deletions

View File

@ -2,8 +2,14 @@ import { useValidator } from 'src/composables/useValidator';
export function useRequired($attrs) {
const { validations } = useValidator();
const isRequired = Object.keys($attrs).includes('required');
const hasRequired = Object.keys($attrs).includes('required');
let isRequired = false;
if (hasRequired) {
const required = $attrs['required'];
if (typeof required === 'boolean') {
isRequired = required;
}
}
const requiredFieldRule = (val) => validations().required(isRequired, val);
return {