| Name | Type | Description |
|---|---|---|
| record | sys.data.Record | The record that contains the field to validate. |
| parentField | sys.data.Record | This variable is only available when this is a field inside a nested field and it is based on the
variable It is a sys.data.Record object with the difference that the root of the record is set to the
nested fields containing it. This way it is possible to access fields in the nested group like
|
| field | sys.data.Wrapper | The field wrapper to validate. Check «<sys.data.Wrapper»> docs for more info about how to manipulate it. |
| action | sys.data.Action | This variable will be available only if the field is an action parameter. It will provide access to other parameters, but keep in mind that they might be empty (except that they have an initial value set). |
object -You should return an object representing the error, something like this:
{code: 'invalid', message: 'This is not a valid US zip code'}
Where code is the error code. You can put whatever makes sense to you and it will be sent in
the response when trying to create/update a record using the REST API or the exception info when
saving a record with the Javascript API.
message is what will be displayed in the UI and also sent as response together
with the code.
In case that field is valid, we should not return anything.
//validates the zip code using an expression
var zipValue = field.val();
if (zipValue && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(zipValue)) {
return {code: 'invalid', message: 'This is not a valid US zip code'};
}
//validates the zip code using an external service
var zipValue = field.val();
if (!app.endpoints.addressValidator.isValidZipCode(zipValue)) {
return {code: 'invalid', message: 'This is not a valid US zip code'};
}