6.2.4 Format Validation

Our validations for the name attribute enforce only minimal
constraints—any non-blank name under 51 characters will do—but of course
the email attribute must satisfy more stringent requirements. So far
we’ve only rejected blank email addresses; in this section, we’ll
require email addresses to conform to the familiar pattern
user@example.com.

Neither the tests nor the validation will be exhaustive, just good
enough to accept most valid email addresses and reject most invalid
ones. We’ll start with a couple tests involving collections of valid and
invalid addresses. To make these collections, it’s worth knowing about
the useful %w[] technique for making arrays of strings, as seen in this
console session: