Skip to content

This how-to is for builders and the developers who work with them. Some rules are too involved for a field’s own settings — “the end date must be after the start date, unless the request is open-ended”, “a reference number must pass a check-digit test”. A validator function checks the record on the server before it is saved, and stops the save with your own message when the rule fails.

You will write the function, attach it to an entity (to check the whole record) or to a field (to check one value), and give each failure a message people understand.

You need:

  • The system Admin level, to add functions. See Functions: run your own code.
  • Developer access on the module, to attach the validator to the entity or field.
  • A developer who can build a small TypeScript function, or a function your team already has.
KindWhat it checksWhen it runsAttached on
Standalone ValidatorThe whole record, and the version before the changeBefore Save (a new record), Before Edit (a change) or Before ArchiveThe entity’s Form Settings
Value ValidatorOne field’s valueOn Save — when a record is created or changedThe field’s Field Settings

Both run on the server, so they apply however the record is saved — from a form, a reaction or the HTTP API.

The platform calls your function with the record, and reads its answer from result. Return success: true at the top level whenever your function ran, and put the verdict inside result:

Your ruleReturn
Passes{ "success": true, "result": { "success": true } }
Fails{ "success": true, "result": { "success": false, "errors": [{ "errorCode": "END_BEFORE_START" }] } }

The function receives dataEntry — the record as it will be saved — and, on Before Edit, existingEntry, the record before the change. Field values are under value, by the field’s system name.

src/index.ts
import { Context } from 'faas-js-runtime';
const handle = async (context: Context) => {
const body = (context.body ?? {}) as any;
const { dataEntry, existingEntry } = body.data ?? body;
const v = dataEntry?.value ?? {};
const errors: { errorCode: string }[] = [];
if (v.start_date && v.end_date && new Date(v.end_date) < new Date(v.start_date)) {
errors.push({ errorCode: 'END_BEFORE_START' });
}
// On an edit, refuse to lower the approved amount.
const before = existingEntry?.value?.approved_amount;
if (before != null && Number(v.approved_amount) < Number(before)) {
errors.push({ errorCode: 'AMOUNT_LOWERED' });
}
return {
success: true,
result: errors.length ? { success: false, errors } : { success: true },
};
};
export { handle };

On Before Archive the function receives only dataEntry: the record being archived.

The function receives { value } — just the field’s value. For a field that holds several values, it is called once for each value. An empty value is not sent to it.

src/index.ts
import { Context } from 'faas-js-runtime';
// A reference number: 8 digits, the last one a check digit.
const handle = async (context: Context) => {
const body = (context.body ?? {}) as any;
const { value } = body.data ?? body;
const digits = String(value ?? '');
const valid =
/^\d{8}$/.test(digits) &&
[...digits.slice(0, 7)].reduce((sum, d) => sum + Number(d), 0) % 10 ===
Number(digits[7]);
return {
success: true,
result: valid
? { success: true }
: { success: false, errors: [{ errorCode: 'BAD_CHECK_DIGIT' }] },
};
};
export { handle };

Build, try and package the function as described in Write a function.

A standalone validator runs only for the entity it belongs to, so add it from that entity:

  1. Open Administration › Applications › Modules, open the module, and open the entity — for example Leave requests.
  2. Select the Functions tab, then New Function (Add Function when the list is empty).
  3. Enter a Name, and choose the Type: Standalone Validator or Value Validator.
  4. Upload the ZIP and save. Wait until the status is Provisioned — see Add the function.
  5. Under Errors, add one row for each code your function returns: the Error Code exactly as the function returns it — for example END_BEFORE_START — and the Error Message people see, in each language.
Error CodeError Message
END_BEFORE_STARTThe end date must be on or after the start date.
AMOUNT_LOWEREDThe approved amount cannot be lowered.
BAD_CHECK_DIGITThis reference number is not valid. Check the last digit.

Check the whole record: a standalone validator

Section titled “Check the whole record: a standalone validator”
  1. In the entity’s designer, open the Structure tab.
  2. Select the settings icon to open Form Settings.
  3. Open Standalone Validator and select Add Standalone Validator.
  4. Enter a Name, choose the function in Standalone Function, and choose when it runs in Standalone Trigger: Before Save, Before Edit or Before Archive.
  5. Leave Activated on, and save.

Each validator in the list has a switch to turn it off without deleting it, and an Edit button. To check both new records and changes, add the function twice: once with Before Save and once with Before Edit.

  1. On the Structure tab, select the field’s settings icon to open Field Settings.
  2. Find Value Validators. Pick existing validators in Select Value Validators, or select Add Value Validator to create one: a Name, the function in Value Function, and On Save in Value Trigger.
  3. Save the field, then save the entity.

A value validator is reusable: attach the same one to every field that holds the same kind of value. Value Validators is not offered on blocks, virtual fields or display-only fields.

When a validator fails, the record is not saved and the person sees the Error Message you entered for each code — in a message on the form, and, for a value validator, next to the field it checked. A code with no row under Errors is reported with no text, so add every code.

How several validators combine:

  • Standalone validators run one after another. The first one that fails stops the check, and only its errors are shown.
  • Value validators are checked field by field. Each field shows the errors of its first failing validator, and errors from different fields are shown together.
  • A validator whose Activated switch is off is skipped.
  1. Open the entity’s form and enter values that break the rule — an end date before the start date.
  2. Save. The record is not saved, and your message appears.
  3. Correct the value and save again. The record is saved.
  4. If you attached Before Edit, open an existing record and repeat.
ProblemWhat to check
The save goes through although the rule failsThe function is not Provisioned or not active, or the validator’s Activated switch is off. A validator whose function is not ready is skipped.
A standalone validator never runsThe function was added from another entity, or at system or module level. Add it from the entity’s Functions tab.
The save fails with a technical error, not your messageYour function returned a top-level success: false, did not answer with JSON, or crashed. Return success: true and put the verdict in result.
The message is emptyThe code the function returns has no matching Error Code row, or differs in spelling or case.
A rule on a new record does not run on editsBefore Save covers new records only. Add the validator again with Before Edit.
Restoring an archived record skips the ruleValidators do not run when a record is restored.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27