PassValidator: AtLeastTwoDigits Requirement
Extend the Validate function with another rule.
We'll cover the following
So far, our Validate
function has been limited since it can only handle the scenario where the input password is shorter than eight characters. Let’s enrich it with a new requirement.
At least two digits requirement
This requirement states that the password is valid only if it has at least two digits among its characters. If this requirement is not met, the function has to return the password must contain at least 2 numbers
error.
The Red phase
To enter into the Red phase, we’ll write a test for the value abcdefgh1
:
Get hands-on with 1200+ tech skills courses.