Server Data Validation

View as Markdown

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: true
boolean
Displays a Notification Message after Server Validation
Server Validation
Fork
  • In this (very contrived) example the rating column is editable but values must be between 10 and 20 (with 15 not allowed). Logic is in adaptableOptions.ts.
  • Three server validation outcomes (each can display a message):
    • value > 20 returns 20 — messageType Warning and custom header
    • value < 10 returns 10 — no messageType (defaults to Info)
    • value exactly 15 is rejected — messageType Error and custom header
  • Edits that do not break those rules, or edits outside rating, are left unchanged by the validator.
Loading demo…