Description
#272 seems to have introduced a regression when using custom validations and multiple rules between 1.11.1 and 1.12.0.
If there are multiple rules, and an earlier rules fails while a later rule passes, the validation will still fail.
In this example codesandbox, you'll see a custom rule for a simple "even number" example. When using 1.12.0
, the "Array passing" rule is failing, even though it should pass. If you change the version of fastest-validator
to 1.11.1
then this same validation will be successful.
I debugged through a bit and I believe the problem is in makeCustomValidator
method. Errors that come back from custom validators are pushed on to the main errors
array. This wasn't a problem in 1.11.1
because the multi validator code used to confirm if the number of errors had changed between each validation, but in 1.12.0
it is instead using different variables for the results of each validation and conditionally pushing those results on to the errors array. However, because the custom validator is itself pushing on to the errors array, the multi validator's behavior is not occurring as expected.