Skip to main content

InputValidator

The InputValidator makes it easy to perform common validation, such as email validation.

Usage#

When 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:

  1. True - Error occured
  2. False - No Error
  3. string - Custom error text. Will be returned instead of true

Chaining Functions#

It 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#

Email#

new InputValidator("Input Value").email("Optional Error Text").result

CPR#

new 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