Server Data Validation
Summary
- Server-side validation can be used to validate (and undo) Edits via a function
- An optional Message can be displayed to the User
AdapTable provides Server Validation, i.e. validation through a function provided by the user.
Find Out More
AdapTable also offers Client Validation where the validation is handled using Validation Alerts
This is available via the validateOnServer property in Edit Options.
If provided, the async function will be invoked by AdapTable each time a cell is edited.
Caution
This function will only be called after Client Validation has successfully completed
The function receives full details of the proposed edit and returns one of 3 outcomes for newCellValue:
- nothing (empty result) — the edit is valid, or you will update data via the API or another mechanism
- the old value — validation failed; return the cell to its previous value
- a different value — often used when the new value breaches upper or lower bounds (see example below)
validateOnServer
Runs Validation of Data Edits on the Server
displayServerValidationMessages
Default: truebooleanDisplays a Notification Message after Server Validation
Server Validation
- In this (very contrived) example the
ratingcolumn is editable but values must be between 10 and 20 (with 15 not allowed). Logic is inadaptableOptions.ts. - Three server validation outcomes (each can display a message):
- value
> 20returns20—messageTypeWarning and custom header - value
< 10returns10— nomessageType(defaults to Info) - value exactly
15is rejected —messageTypeError and custom header
- value
- Edits that do not break those rules, or edits outside
rating, are left unchanged by the validator.
Loading demo…