In this exercise, you will define some validation functions that check user inputs (such as from DOM elements). You'll need to properly handle the coercions of the various value types.
-
Define an
isValidName(..)
validator that takes one parameter,name
. The validator returnstrue
if all the following match the parameter (false
otherwise):- must be a string
- must be non-empty
- must contain non-whitespace of at least 3 characters
-
Define an
hoursAttended(..)
validator that takes two parameters,attended
andlength
. The validator returnstrue
if all the following match the two parameters (false
otherwise):- either parameter may only be a string or number
- both parameters should be treated as numbers
- both numbers must be 0 or higher
- both numbers must be whole numbers
attended
must be less than or equal tolength