Skip to main content
Version: 2.14.0

Validators

Data validation can be enforced using Validators.

Some Angular default validators are available:

  1. min
  2. max
  3. minLength
  4. maxLength
  5. required
  6. email

Other predefined validators are also available:

  1. isSameOrBeforeToday: validates that a datepicker value is in the pas
  2. isSameOrAfterToday: validates that a datepicker value is in the future

Form validation is triggered by default when the button set to validate the Form Group is pressed.

It's also possible to build custom validators inside the container application and reference them here by name.

Predefined validators

1. required

A required validator checks if the value exists.

Important to be used with other validators like a minlength one to check if there is no value at all.

required validator

2. minlength

Checks if the value has a minimum number of characters (no character at all will not trigger this validator so better use it together with a required validator).

minlength validator

3. maxlength

Checks if the value has a maximum number of characters (no character at all will not trigger this validator so better used with a required one).

maxlength validator

4. min

Checks if a numeric value is smaller (no character will trigger this validator so better use it with a required one).

min validator

5. max

Checks if a numeric value is smaller (no character will trigger this validator so better use it with a required one).

max validator

6. email

Checks if you entered an email (no character will not trigger this validator so better used with a required one).

email validator

7. pattern

Checks if you entered a string that respects a pattern (in this case, a regex).

8. isSameOrBeforeToday

It can be added to datepicker fields.

Checks a date is today or in the past (no character will trigger this validator so better use it with a required one).

isSameOrBeforeToday

9. isSameOrAfterToday

Checks a date is today or in the past (no character will trigger this validator so better use it with a required one).

Custom validators

Custom validators can be created by a developer in the web application before you can use them.

Available configurations are:

  1. Validator name - name provided by the developer to uniquely identify the validator
  2. Type - sync/ async validator (for more details check this)
  3. Error Message - The message that will be displayed if the field is not valid
  4. Validator parameters - if the validator needs inputs to decide if the field is valid or not, you can pass them using this list

NOTE: the error that the validator returns MUST match the validator name.

custom validator

For more details about custom validators please check this link.


Was this page helpful?