Open MercatoDocsSearch docsAPI reference

Framework

Custom field validation

A customer-specific field can still have a firm rule. Define it alongside the field, give the person entering the value a useful error message, and enforce the same rule when an API client submits the record.

Custom field definitions support rule-based validation with custom error messages. Rules are enforced in the UI (CrudForm) and revalidated on the server in APIs handling custom user entities.

Supported rules:

Definition syntax (configJson.validation):

validation: [
  { rule: 'required', message: 'Required' },
  { rule: 'integer', message: 'Must be integer' },
  { rule: 'gte', param: 1, message: '>= 1' },
  { rule: 'lte', param: 5, message: '<= 5' },
  { rule: 'regex', param: '^[a-z0-9_-]+$', message: 'Invalid slug' },
]

UI behavior:

Server behavior:

Shared helper:

Previous: Admin forms with CrudForm · Next: Building data grids