validatorjs
validatorjs copied to clipboard
Min rule is broken for empty strings
min
rule is working wrong for empty strings. Here is an example:
import Validator from 'validatorjs'
const data = {
name: '',
surname: ''
}
const rules = {
name: 'required',
surname: 'min:2'
}
const validation = new Validator(data, rules)
if (validation.fails()) {
console.log(validation.errors.all())
}
Errors are:
{ name: [ 'The name field is required.' ] }
However, surname
is an empty string and min:2
rule didn't return error.
Tested with [email protected]