Fields

A field corresponds to an input parameter and a form data property. It is associated with a sequence of validations. The field is said to be valid if all validations in the sequence succeed. We say, the input is mapped by that field, meaning that the form data property of that field will be set to the field's value.

Field validations fall into three categories: matchers, converters and checkers. A field's validation sequence consists of zero or more matchers, followed by zero or one converter, followed by zero or more checkers.

  1. A matcher takes a string as input and produces a string as a result. As the name suggests, the result string usually should be a substring of the input string. However, this is not required. Typical matchers strip whitespace or match against a regular expression.
    Matchers are connected as a pipeline: the first matcher takes the original form parameter as input. A matcher's output is taken as input by its successor.
  2. The converter takes a string as input and produces an object as result. It parses a string to produce an object of some type, eg a number or date.
    The converter takes the result of the matcher pipeline as its input.
  3. A checker takes an object and performs some tests on it. As its result, it returns a boolean to indicate success or failure. Typical checkers may perform range tests on numbers or dates, length tests on strings, and so on.
    A checker takes the converted value as input.

There's a one-to-one correspondence between fields and form data properties. Usually, a field also corresponds to one input parameter.

Advanced
However, there may be more than one field for an input parameter. In this case, the input is mapped by the first valid field. The form data properties corresponding to the other fields for that input will be set to null. For example, this feature may be used to have an input that may contain a date or a number.

When a field validation fails, Calyxo marks the corresponding input to enable visual feedback to the user. For example, invalid input fields may be colored red.