Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Basic validations regarding data types will be specified by the underlying Form Schema of the form like the data type of a form or number ranges for example.

In order to create more specific custom validation rules for form fields, you can add the validation attribute to each field in the Form Config. For example:

Code Block
languagejson
{
  "title": "Person",
  "description": "A person form",  
  ...
  
  "layout": {
    "items": [
      {
        "field": "firstName", 
        "validation":[
          { "type":"js", "rule":"!!val", "message": "Field is required!" },
          { "type":"js", "rule":"val.length > 2", "message": "Must be longer than 2 chars!" }
        ]
      },
      ...
    ]
  }
}

...

This will produce the Field is required! message if the respective field is not given, as seen below:.

Info

The expression !!val is just a shorter form of !(val == null)

Example: Number ranges (min / max)

...