Objectives

This is just a short demonstration of some basic regular expressions.

Regex in Hapi

Updating accounts.js with he following implements two slightly different basic regular expressions as well as a minimum password length requirement.

payload: {
  // begin with upper case letter and then 2+ lower case letters
  firstName: Joi.string().regex(/^[A-Z][a-z]{2,}$/),        

  // begin with upper case letter, then any 2+ characters
  lastName: Joi.string().regex(/^[A-Z]/).min(3),         
  email: Joi.string().email().required(),

  password: Joi.string().min(8)               // min 8 characters
},

More regular expressions

A web search will quickly give you lots more tutorial examples of regular expressions. You can also find online regular expression tools, such as https://regex101.com/

Validating a CAO code

Key