repocrypts / Validator

Client-side javascript validator library ports from Laravel 5.2
MIT License
46 stars 22 forks source link

Error logged when validating an after:date rule #30

Closed filipesantoss closed 4 years ago

filipesantoss commented 4 years ago

When validating an after:date rule, a console.error call is made. I believe this behavior, which seems to stem from here, is not expected and hereby inquire about its removal.

As an example, the following code

const Validator = require('Validator');

const data = {
    firstDate: null 
};

const rules = {
    firstDate: 'date',
    secondDate: 'date|after:firstDate',
};

const validator = Validator.make(data, rules);

if (validator.fails()) {
    console.log(validator.getErrors());
}

produces the following output

firstDate does not appear to be a date.
{
  firstDate: [ 'The first date is not a valid date.' ],
  secondDate: [
    'The second date is not a valid date.',
    'The second date must be a date after first date.'
  ]
}