PassValidator: AtLeastACapitalLetter Requirement
Build a feature that will allow only passwords with at least one capital letter within them.
We'll cover the following
Before moving on, let’s recap what we’ve done so far in the Validate
function:
- It manages the password with less than eight characters and gives back the
ErrToShort
error. - It manages the password with less than two numbers and gives back the
ErrTooFewDigits
error. - It manages these two requirements at the same time.
Let’s explore the next feature we’re going to implement.
At least one capital letter requirement
This requirement forces the password to have at least one capital letter. If the password doesn’t meet it, the Validate
function returns the password must contain at least one capital letter
error.
The Red phase
To enter the Red phase, we’re going to write a test for the value abcdef1234
. Let’s see this in the next code snippet:
Get hands-on with 1400+ tech skills courses.