Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

validator

Used to declare a field validator

 

  1. validator FirstnameValidator 
  2. {
  3.     minlen(2); maxlen(250);
  4. }
  5. validator AgeValidator 
  6. {
  7.     minval(0);
  8. }

 

Atomic validators

These are the building blocks used for creating complex validators

 

notnull

Check that the attribute is not null. This validator does not take any arguments.

 

regex

Checks that the value conforms to a regular expression.

 

  1. // Allows upper & lower case and spaces
  2. regex("^[A-Z a-z]*$");
  1. // Alphanumeric with spaces
  2. regex("^[A-Za-z0-9 ]*$");
  1. // Number starting with 27
  2. regex("^27[0-9]*$");
  1. // Email
  2. regex("\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]{2,4}\b");

 

minval

Checks that the value is not less than the supplied minimum value.

 

  1. minval(3.145);

 

maxval

Checks that the values is not greater than the supplied maximum value.

 

  1. maxval(6.18);

 

minlen

Checks that a string value does not have less characters than the supplied minimum value.

 

  1. minlen(2);

 

maxlen

Checks that a string value does not have more characters than the supplied maximum value.

 

  1. maxlen(255);

 

 

  • No labels