#5878 - FiscalData Validations #108
|
@ -30,6 +30,15 @@ export function useValidator() {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const validations = function (validation) {
|
const validations = function (validation) {
|
||||||
return {
|
return {
|
||||||
|
format: (value) => {
|
||||||
|
const { allowNull, with: format, allowBlank } = validation;
|
||||||
|
const message = t(validation.message) || validation.message;
|
||||||
|
if (!allowBlank && value === '') return message;
|
||||||
|
if (!allowNull && value === null) return message;
|
||||||
|
|
||||||
|
const isValid = new RegExp(format).test(value);
|
||||||
|
if (!isValid) return message;
|
||||||
jsegarra marked this conversation as resolved
Outdated
|
|||||||
|
},
|
||||||
presence: (value) => {
|
presence: (value) => {
|
||||||
let message = `Value can't be empty`;
|
let message = `Value can't be empty`;
|
||||||
if (validation.message)
|
if (validation.message)
|
||||||
|
|
Loading…
Reference in New Issue
Tienes instalado eslint, el código no respeta las reglas: falta punto y coma al final de las líneas, espacio despues del if...
He corregido el problema, y anotado la causa del error para comentar en la próxima reunión.