Search⌘ K

PassValidator: AtLeastACapitalLetter Requirement

Understand how to implement and test the requirement that passwords must contain at least one capital letter. Explore writing TDD test cases in Go, applying regex for validation, and improving code quality through refactoring to ensure robust password validation.

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 ...