Lesson 3: Validation functions

Contents
  • Project setup
  • maxLength
  • allAlpha
  • stripSpace
  • Exercise
Video
  • 15 minutes

In this lesson we get into the code that we will stay with through the rest of the course. We will be writing code for validating passwords and usernames, and constructing a user that is a product of the two. We start in this lesson with just passwords.

We will write three functions. One checks a String for a maximum length. The second verifies that a String input is all alphanumeric characters – no special characters allowed in our passwords! The third will strip any leading white space off of a String input. All three return a Maybe String, so invalid inputs are all Nothing. This lesson ends with an exercise.

Sign up for access to the full page, plus the complete archive and all the latest content.