Data validation
Validate ranges and required input using per-column rules.
Options
Changes below update the Grid and code immediately.
Edit Quantity, enter -1, and try to apply it. Quantities in this example must be at least 0.
View code
Sample data included in the code · 6 rows
Usage guide
#Block values forbidden by business rules, such as negative quantities. Check both input formats and business constraints.
Try it yourself
- Enter a disallowed value
Edit Quantity, enter -1, and try to apply it. Quantities in this example must be at least 0.
- Verify the previous value is retained
Check that the disallowed value does not remain as a valid quantity. Numeric editor restrictions or validation rules prevent application.
- Enter a valid value
Enter 25 in the same cell and press Enter. Verify quantity and total update correctly.
Valid input is applied and out-of-range input is blocked. If validation events fire, read their reasons in the results.
Browser validation alone does not protect server data. Enforce the same business rules in the save API.
Useful terms
- validationRules
- A list defining which validation conditions apply to each column.
- invalidEditMode: block
- A setting blocking edits that fail validation.
API reference
#Other properties2
| Attribute / Property | Type / Default | Description |
|---|---|---|
| validationRules | ValidationRule[]Default: undefined | Data validation. A grid-level list of per-column rules (required / number / integer / min / max / range / minLength / maxLength / pattern / oneOf / custom). A failing cell is MARKED invalid (a red state + the message as its title) — the edit is NOT blocked (the value lands, the cell flags it, spreadsheet-style by default). `invalid-edit-mode` can instead keep the editor open (`block`) or cancel/revert it (`revert`). A rejected or allowed-invalid edit fires `cellValidationFailed`. Blank passes every rule but `required`. Off by default (zero overhead). |
| invalidEditMode | 'allow' | 'revert' | 'block'Default: 'allow' | Policy for an editor value that fails `validationRules`. `allow` preserves the existing spreadsheet-style mark-and-commit behavior. |
Events1
| Events | Detail type | Description |
|---|---|---|
{ rowIndex: number; field: string; value: unknown; message: string } | Fires when a committed edit fails a validation rule. |
Methods1
| Method / Arguments | Return type | Description |
|---|---|---|
Promise<
Array<{ rowIndex: number; rowId: unknown; field: string; value: unknown; message: string }>
> | every cell that currently fails a validation rule, in display order. Empty when there are no rules (zero overhead). A host uses this for an error summary / "jump to next error" / a save-guard. |
Explore each feature
Learn when to use each feature and how to configure it. Each guide identifies live examples and features you connect in your app.