PassValidator: MultipleErrors Requirement

Implement the scenario in which there’s more than one validation error at the same time.

Before we implement the other features of the Validate function, let’s recap what we have managed until now:

  • We check if the password has at least eight characters.
  • We check if the password has at least two digits.

What if the password is shorter than eight characters and also has less than two digits? In this case, we should return both of the encountered validation errors, not just the first one ( ErrTooShort).

The MultipleErrors requirement

This feature should be able to manage a password like abc1 and return the error ErrTooShort together with the ErrTooFewDigits one.

The Red phase

Let’s write a test for the value abc1 and see the actual behavior of the Validate function.

Get hands-on with 1200+ tech skills courses.