Field Validation
To ensure data accuracy, security, and consistency in collections, NocoBase provides field validation functionality. This feature consists of two main parts: rule configuration and rule application.
Rule Configuration

NocoBase system fields integrate Joi rules, with support as follows:
String
Joi string types correspond to the following NocoBase field types: Single Line Text, Long Text, Phone, Email, URL, Password, and UUID.
Common Rules
- Min length
- Max length
- Length
- Pattern
- Required

URL

UUID

Number
Joi number types correspond to the following NocoBase field types: Integer, Number, and Percentage.
Common Rules
- Greater than
- Less than
- Max value
- Min value
- Multiple
Integer
In addition to common rules, integer fields additionally support integer validation and unsafe integer validation.

Number & Percentage
In addition to common rules, number and percentage fields additionally support precision validation.

Date
Joi date types correspond to the following NocoBase field types: Date (with timezone), Date (without timezone), Date only, and Unix timestamp.
Supported validation rules:
- Greater than
- Less than
- Max value
- Min value
- Timestamp
- Required
Association Fields
Association fields only support required validation. Note that required validation for association fields is currently not supported in sub-form or sub-table scenarios.

Applying Validation Rules
After configuring field rules, the corresponding validation rules will be triggered when adding or modifying data.

Validation rules also apply to sub-table and sub-form components:


Note that in sub-form or sub-table scenarios, required validation for association fields does not take effect.

Differences from Client-Side Field Validation
Client-side and server-side field validation are applied in different scenarios, with significant differences in implementation and rule trigger timing, so they need to be managed separately.
Configuration Method Differences
- Client-side validation: Configure rules in edit forms (as shown in the figure below)
- Server-side field validation: Set field rules in Data Source → Collection Configuration


Validation Trigger Timing Differences
- Client-side validation: Triggers validation in real-time as users fill in fields, displaying error messages immediately.
- Server-side field validation: Validates on the server side before data entry after data submission, with error messages returned through API responses.
- Application scope: Server-side field validation takes effect not only during form submission but also triggers in all scenarios involving data addition or modification, such as workflows and data imports.
- Error messages: Client-side validation supports custom error messages, while server-side validation does not currently support custom error messages.

