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:
-
Inside client-script on
beforeFormSubmit
event, -
inside server-script on
before
events, -
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
-
Dispatch
beforeFormSubmit
event,-
if any automation script returns a
validator.ValidatorError
, stop the execution and show the errors,
-
-
run the
validator.RecordValidator
system,-
on
validator.ValidatorError
, dispatch theonFormSubmitError
event that can be used to fix the validation errors, -
run the
validator.RecordValidator
system,-
if errors persist, stop the execution and show the errors,
-
-
-
request record create/update on the API,
-
if the API returns a
validator.ValidatorError
, stop the execution and show the errors.
-