npm run validator-example
In this example we create a user validator.
The validator will emit a validation error if any of the following conditions are met.
- Missing First or Last Name
- First or Last Name are > 10 characters
- First or Last Name contain numeric characters.
- Missing DOB
- DOB > 100 years old.
- DOB < 18 years old.
- Missing Email Address
- Invalid Email Address.
- Non unique Email Address.
validation-example: Example 1 - User(id: 12, firstName: Sally, lastName: GregorianCalendar, dob: 1980-11-10T06:00:00.000Z, email: [email protected]) is invalid 'Email is not unqiue'
validation-example: Example 1 - User(id: 13, firstName: Sally, lastName: Yukon, dob: 1980-11-10T06:00:00.000Z, email: [email protected]) is invalid 'Email is not unqiue'
validation-example: Example 1 - User(id: 12, firstName: Sally, lastName: GregorianCalendar, dob: 1980-11-10T06:00:00.000Z, email: [email protected]) is invalid 'Last name cannot be longer than 10 characters'
validation-example: Example 1 - User(id: 11, firstName: Bobalicious, lastName: Yukon, dob: 1980-11-10T06:00:00.000Z, email: [email protected]) is invalid 'First name cannot be longer than 10 characters'
validation-example: Example 1 - User(id: 10, firstName: Bob, lastName: Yukon1, dob: 1980-11-10T06:00:00.000Z, email: [email protected]) is invalid 'Last name is must not contain numbers'
validation-example: Example 1 - User(id: 9, firstName: Bob1, lastName: Yukon, dob: 1980-11-10T06:00:00.000Z, email: [email protected]) is invalid 'First name is must not contain numbers'
validation-example: Example 1 - User(id: 7, firstName: Bob, lastName: Yukon, dob: 1980-11-10T06:00:00.000Z, email: bob@yukon) is invalid 'Invalid email address'
validation-example: Example 1 - User(id: 6, firstName: Bob, lastName: Yukon, dob: 1980-11-10T06:00:00.000Z, email: bob) is invalid 'Invalid email address'
validation-example: Example 1 - User(id: 5, firstName: Bob, lastName: Yukon, dob: 1980-11-10T06:00:00.000Z, email: undefined) is invalid 'Invalid email address'
validation-example: Example 1 - User(id: 4, firstName: Bob, lastName: Yukon, dob: 2000-11-10T06:00:00.000Z, email: undefined) is invalid 'Date Of Birth must be >= 18 years ago'
validation-example: Example 1 - User(id: 4, firstName: Bob, lastName: Yukon, dob: 2000-11-10T06:00:00.000Z, email: undefined) is invalid 'Invalid email address'
validation-example: Example 1 - User(id: 3, firstName: Bob, lastName: Yukon, dob: null, email: undefined) is invalid 'Date of birth is required'
validation-example: Example 1 - User(id: 3, firstName: Bob, lastName: Yukon, dob: null, email: undefined) is invalid 'Invalid email address'
validation-example: Example 1 - User(id: 2, firstName: Bob, lastName: undefined, dob: null, email: undefined) is invalid 'Last name is required'
validation-example: Example 1 - User(id: 2, firstName: Bob, lastName: undefined, dob: null, email: undefined) is invalid 'Date of birth is required'
validation-example: Example 1 - User(id: 2, firstName: Bob, lastName: undefined, dob: null, email: undefined) is invalid 'Invalid email address'
validation-example: Example 1 - User(id: 1, firstName: undefined, lastName: undefined, dob: null, email: undefined) is invalid 'First name is required'
validation-example: Example 1 - User(id: 1, firstName: undefined, lastName: undefined, dob: null, email: undefined) is invalid 'Last name is required'
validation-example: Example 1 - User(id: 1, firstName: undefined, lastName: undefined, dob: null, email: undefined) is invalid 'Date of birth is required'
validation-example: Example 1 - User(id: 1, firstName: undefined, lastName: undefined, dob: null, email: undefined) is invalid 'Invalid email address'
validation-example: Example 1 - User(id: 8, firstName: Bob, lastName: Yukon, dob: 1980-11-10T06:00:00.000Z, email: [email protected]) is valid