Skip to main content

Validation

Prop enableValidation — engine behaviour, default false.

Guide

When to use it

Add validation whenever bad input must be caught before it reaches your data — required fields, number ranges, cross-column rules, or an async check against the server.

How it works

enableValidation runs your column / row validators on every edit and surfaces failures inline (an error ring + message on the cell). The policy option decides what a failure does:

  • blockCommitOnError (default) — the edit can't commit until it's valid.
  • commitButFlag — the edit commits but the cell stays visibly flagged (useful for import-then-fix workflows).
<BstTableMui
data={rows}
columns={columns}
getRowId={(r) => r.id}
enableEditing
enableValidation={{ policy: 'blockCommitOnError' }}
/>

Validators live on the column (meta) and can be sync or async; cross-column rules see the whole row.

Gotchas

  • Requires enableEditing — there's nothing to validate without an edit session.
  • Async validators race: the engine keeps the latest result, but debounce server checks so you don't fire one per keystroke.
  • commitButFlag lets invalid data into your onDataChange / onSave payload by design — check row.getIsValid() before a hard save if that matters.

Live example

Example source
import React from 'react'
import { BstTableMui } from '@bloomskill/table-mui'
import type { BstTableColumn } from '@bloomskill/table-engine'
import '@bloomskill/table-engine/styles.css'
type Row = { id: string; name: string; team: string; role: string; score: number }
const seed: Row[] = [
{ id: '1', name: 'Ada Lovelace', team: 'Platform', role: 'Engineer', score: 92 },
{ id: '2', name: 'Alan Turing', team: 'Research', role: 'Scientist', score: 88 },
{ id: '3', name: 'Grace Hopper', team: 'Platform', role: 'Engineer', score: 95 },
{ id: '4', name: 'Katherine J.', team: 'Research', role: 'Analyst', score: 90 },
{ id: '5', name: 'Edsger Dijkstra', team: 'Platform', role: 'Architect', score: 84 },
]
const columns: BstTableColumn<Row>[] = [
{ id: 'name', accessorKey: 'name', header: 'Name' },
{ id: 'team', accessorKey: 'team', header: 'Team' },
{ id: 'role', accessorKey: 'role', header: 'Role' },
{ id: 'score', accessorKey: 'score', header: 'Score', sortFn: 'basic' },
]
const editable: BstTableColumn<Row>[] = columns.map((c) =>
c.id === 'name'
? { ...c, meta: { type: 'text', editable: true, cellMeta: { required: true } } }
: c.id === 'score'
? { ...c, meta: { type: 'number', editable: true, cellMeta: { required: true } } }
: c,
)
export default function App() {
const [rows, setRows] = React.useState(seed)
// Edit a cell and clear it — the required field is flagged.
return (
<BstTableMui data={rows} columns={editable} getRowId={(r) => r.id}
enableEditing enableValidation onDataChange={setRows} />
)
}
Loading live example…

Overview

Layerenable* (engine, resolved in useBstTable)
Typeboolean | {policy}
Defaultfalse
Maps tocustom feature
Status✅ done (Phase 2)
Sincev0.2.0
Settings sheetEditing

Validation feature. boolean | ValidationOptions. Default: false (opt-in).

Enable it

<BstTableMui
data={rows}
columns={columns}
enableValidation={/* boolean | {policy} */}
/>

Swap BstTableMui for BstTableShadcn (and the CSS import) for the shadcn skin — same props.

Behavior & interactions

  • Requires enableEditing to be on — this flag is a no-op otherwise.
  • Policy 'blockCommitOnError' (default) refuses an invalid commit; 'commitButFlag' accepts and marks it.