Error en validación length solucionado

This commit is contained in:
Juan Ferrer Toribio 2017-05-26 13:26:12 +02:00
parent a73b2eba0d
commit d3ef7dde86
1 changed files with 5 additions and 4 deletions

View File

@ -15,14 +15,15 @@ export const validators = {
max: conf.max || conf.is
};
if (!validator.isLength(value, options)) {
if (conf.is || conf.min === conf.max)
if (conf.is) {
throw new Error(`Value should be ${conf.is} characters long`);
else if (conf.min !== conf.max)
} else if (conf.min && conf.max) {
throw new Error(`Value should have a length between ${conf.min} and ${conf.max}`);
else if (conf.min)
} else if (conf.min) {
throw new Error(`Value should have at least ${conf.min} characters`);
else
} else {
throw new Error(`Value should have at most ${conf.min} characters`);
}
}
},
numericality: function(value, conf) {