0
0
Fork 0

feat: required validation

This commit is contained in:
Javier Segarra 2024-07-16 11:25:06 +02:00
parent 8798598f41
commit fb2e3f1f9c
2 changed files with 5 additions and 3 deletions

View File

@ -46,6 +46,9 @@ export function useValidator() {
return !validator.isEmpty(value ? String(value) : '') || message;
},
required: (required, value) => {
return required ? !!value || t('globals.fieldRequired') : null;
},
length: (value) => {
const options = {
min: validation.min || validation.is,
@ -78,11 +81,9 @@ export function useValidator() {
custom: (value) => validation.bindedFunction(value) || 'Invalid value',
};
};
// const requiredFieldRule = [(val) => validations({}).presence(val)];
return {
validate,
// requiredFieldRule,
validations,
models,
};

View File

@ -67,6 +67,7 @@ globals:
allRows: 'All { numberRows } row(s)'
markAll: Mark all
requiredField: Required field
valueCantBeEmpty: Value cannot be empty
class: clase
type: Type
reason: reason
@ -75,7 +76,7 @@ globals:
notificationSent: Notification sent
warehouse: Warehouse
company: Company
fieldRequired: Field requdired
fieldRequired: Field required
allowedFilesText: 'Allowed file types: { allowedContentTypes }'
smsSent: SMS sent
confirmDeletion: Confirm deletion