Assignment 12

PDF version

due Mon 16 Dec

Starting with the sample code for form processing on December 9 and 11, extend the validation to also check password rules: the password must have length at least 7 (minPasswordLength) and it must contain at least one digit.

There is also a slight problem with how we check for required fields. We’re using T.null (where T is the Data.Text module), which is true when the text string is empty. But a user could satisfy that validation by entering one or more spaces. Try it! If I put a single space as my first name, it will pass validation and the acknowledgment page says “Hello,  ”. There is a function:

T.strip :: T.Text -> T.Text

that will remove any leading or trailing spaces from a text string:

λ> T.strip "   hello  "
"hello"
λ> T.strip "    "
""

So you should use that in combination with T.null to reject strings containing only blanks.

Finally, add one more required text field to the `UserReg` structure, to represent a phone number. The validation rules for phone numbers are that they contain at least 7 digits. They may also contain spaces, hyphens, dots, or parentheses, but no other characters. Add that to the validation rules and the registration form.