You are reading the documentation for an outdated Corteza release. 2023.9 is the latest stable Corteza release.

Corteza Low Code

Record Value Validation

Record value validation allows us to assure data integrity and avoid problems consisting of empty fields and malformed email addresses.

Value validation can also perform operations that require API access, such as checking if we can send an email to the given address.

Value validation can be performed on 3 places:

  1. Inside client-script on beforeFormSubmit event,

  2. inside server-script on before events,

  3. automatically by the corteza-server value validator.

All validator errors returned by automation scripts are instances of validator.ValidatorError class, with the interface of:

interface ValidatorError {
  kind: string;(1)
  message: string;(2)
  meta: { [key: string]: unknown };(3)
}
1 The kind of the error; for now, this can be an arbitrary string that describes the error.
2 The optional message with a more verbose error description. Defaults to err.kind.
3 A loosely defined object that stores any additional metadata, such as field name, recordID, …​

The validation flow

  1. Dispatch beforeFormSubmit event,

    • if any automation script returns a validator.ValidatorError, stop the execution and show the errors,

  2. run the validator.RecordValidator system,

    1. on validator.ValidatorError, dispatch the onFormSubmitError event that can be used to fix the validation errors,

    2. run the validator.RecordValidator system,

      • if errors persist, stop the execution and show the errors,

  3. request record create/update on the API,

    • if the API returns a validator.ValidatorError, stop the execution and show the errors.