Framework
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:
param number)param; on integer/float fields numeric strings are parsed with Number() like lt/gt ('5' equals 5), other kinds compare strictlyDefinition 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:
entityId, displays an asterisk when a required rule is present, and validates client-side before submitting.Server behavior:
{ error: 'Validation failed', fields: { cf_<key>: 'Message' } } with 400 on errors.Shared helper:
packages/shared/src/modules/entities/validation.ts exports validateValuesAgainstDefs(values, defs) to evaluate rules.Previous: Admin forms with CrudForm · Next: Building data grids