Handsontable validator dev

From handsontable/handsontable · View interactive version

Handsontable validator dev is an AI agent skill from the GitHub repository handsontable/handsontable. Use when creating or modifying a Handsontable cell validator - async callback-based validation functions that determine if cell values are valid

How to use this skill

Skill file

Handsontable Validator Development

Signature

function myValidator(value, callback) {
  // `this` is bound to the cell's cellProperties object
  if (this.allowEmpty && (value === null || value === undefined || value === '')) {
    return callback(true);
  }
  callback(isValid(value)); // true = valid, false = invalid
}

Rules

Files

src/validators/{validatorName}/
  {validatorName}.ts    # Validator function
  index.ts              # Re-exports

Registry: src/validators/registry.ts.

import { registerValidator } from '../../validators/registry';
registerValidator('myValidator', myValidator);

A new built-in validator also needs its entry in src/validators/features.json (validator:<name_in_snake_case>, licensing: "none"; copy a neighbor), and a cell type that uses it lists it in its requires.allOf. The unit suite fails until both exist. A validator folder that is never registered under a name (maxLengthValidator, regExpValidator) goes in the skip list of scripts/utils/feature-manifest.js instead, with the reason. Run npm run generate:feature-manifest --prefix handsontable and commit what it writes. Rules: src/featureManifest/AGENTS.md.

Triggers

Reference implementations

Correcting cell values inside a validator

When a validator writes a corrected value with setDataAtCell, pass a source string ending in 'Validator':

this.instance.setDataAtCell(row, col, correctedValue, 'myCustomValidator');

validateChanges() in core.ts uses the suffix to fold the correction into the change that triggered it, so that change still applies with the corrected value and fires afterChange. Without it, the correction is a separate write that wins over the triggering change (the last write to a cell wins), and the triggering change is dropped with no afterChange.

Common mistakes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.