Skip to content

Instantly share code, notes, and snippets.

@bettdouglas
Created June 19, 2019 12:30
Show Gist options
  • Save bettdouglas/838ee0e61938f7ed57eb258412b49837 to your computer and use it in GitHub Desktop.
Save bettdouglas/838ee0e61938f7ed57eb258412b49837 to your computer and use it in GitHub Desktop.
_validator.ruleFor('name', ()=>text)
..notEmpty()
..withMessage('Please enter a name')
..length(2, 30)
..withMessage('Please enter a reasonable name');
_validator.ruleFor('email', ()=>text)
..notEmpty()
..withMessage('Email cannot be empty')
..emailAddress()
..withMessage('Enter a valid email');
_validator.ruleFor('text', ()=>text)
..notEmpty()
..withMessage('Cannot be empty');
_validator.ruleFor('phone', ()=>text)
..notEmpty()
..withMessage('Phone number cannot be empty')
..matches('[0-9]{0,14}\$')
..withMessage('Phone number doesn\'t seem correct');
_validator.ruleFor('int', ()=>text)
..matches('(?<=\\s|^)[-+]?\\d+(?=\\s|\$)')
..withMessage('Enter a valid number');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment