Skip to main content

Custom Validations

Custom validations let you make the form invalid when a condition is not met. You can apply custom validations to any component, and the error messages will be rendered close to it. Custom validations it's a list of validations. A validation has two parts:

  • expression: It's an expression that returns a boolean. When the returned value is true, the validation is ok and no error will be shown.
  • error message: It's a message that will be shown to the user when the validation is not ok.

For example

ExpressionError Message
{{!num || num % 2 === 0}}{{num}} must be even

or

ExpressionError Message
{{phone || email}}Please fill in at least one contact method

Please note that error messages are shown for a component only when the user wrote the information inside it. Most time it means when the user focus left the input.