InputValidator
The InputValidator makes it easy to perform common validation, such as email validation.
#
UsageWhen using the validator, you must manually call the result
variable at the end of your validation.
new InputValidator("Input Value").exactly(5).result
The result
will always be one of the following:
True
- Error occuredFalse
- No Errorstring
- Custom error text. Will be returned instead oftrue
#
Chaining FunctionsIt is possible to chain validation functions to create complex validations
// Must be an email between 5 and 16 charactersnew InputValidator("Input Value").email().min(5).max(16).result
#
Validation Functions#
Emailnew InputValidator("Input Value").email("Optional Error Text").result
#
CPRnew InputValidator("Input Value").cpr("Optional Error Text").result
#
Min// Minimum 5 charactersnew InputValidator("Input Value").min(5, "Optional Error Text").result
#
Max// Max 5 characternew InputValidator("Input Value").max(5, "Optional Error Text").result
#
Exact// Exactly 5 charactersnew InputValidator("Input Value").email(5, "Optional Error Text").result