@rjsf/validator-ata
v6.6.1
Published
ata-validator based validator for @rjsf/core
Readme
Table of Contents
About
@rjsf/validator-ata plugs ata-validator into react-jsonschema-form as a drop-in alternative to @rjsf/validator-ajv8. The public API mirrors validator-ajv8 so swapping is a one-line change in the validator import. Error format, custom-format hook, custom validation, and error transformation all work the same way.
ata is a JSON Schema validator that targets Draft 2020-12 (98.5% spec compliance, 95.3% schemasafe pass rate) and is Standard Schema compliant. Its differentiators relative to AJV: pattern checks are RE2-backed (no ReDoS surface), and schemas can be compiled at build time for environments where bundle size or CSP restricts runtime codegen.
Installation
npm install @rjsf/validator-ata ata-validatorata-validator is a peer of this package; install it alongside.
Usage
import Form from '@rjsf/core';
import validator from '@rjsf/validator-ata';
<Form schema={schema} validator={validator} />;Customization
import { customizeValidator } from '@rjsf/validator-ata';
const validator = customizeValidator({
customFormats: {
'phone-us': /\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{4}$/,
'area-code': /\d{3}/,
},
ataOptionsOverrides: {
verbose: true,
},
});customizeValidator accepts:
customFormats— same shape asvalidator-ajv8. Values may be aRegExp, an anchored regex source string, or a(value: string) => booleanpredicate.ataOptionsOverrides— plainata-validatoroptions spread on top of the defaults; use this to flipcoerceTypes,removeAdditional,verbose, orabortEarly.additionalMetaSchemas— extra schemas registered viaValidator#addSchemafor cross-schema$refresolution.extenderFn— hook applied against a freshly-builtValidator(e.g. for adding additional formats or schemas in one place).suppressDuplicateFiltering— passthrough to the RJSF error processor; same semantics as invalidator-ajv8.
A Localizer may be supplied as the second argument. ata error objects use the same field names as AJV (keyword, instancePath, schemaPath, params, message, parentSchema), so localizers that mutate message in place port across without changes. The pre-quote dance that the AJV validator runs against ajv-i18n is intentionally not replicated here — ata's error params are frozen, and the existing locale catalogues for AJV are not portable to ata's keyword set.
Differences from validator-ajv8
The ValidatorType contract is identical, and the shared @rjsf/utils schema test suite passes against this validator with the deltas below. Behavior outside of this list mirrors validator-ajv8.
- Precompiled validators are not yet wired through. The
compileSchemaValidatorsandcreatePrecompiledValidatorentrypoints exposed byvalidator-ajv8are slated for a follow-up release that adapts ata'sbundleStandalonecodegen to the RJSF-expectedValidatorFunctionsshape. ajvOptionsOverrides,ajvFormatOptions,AjvClasshave no equivalents and are intentionally not accepted.ataOptionsOverridesreplaces the first; built-in formats are always installed and don't require an opt-in flag.isValidandrawValidationdeep-cloneformDatabefore passing it to ata. ata's default-applier writesdefaultvalues into the input object during validation, while AJV treats validation as a pure operation. The clone preserves the AJV contract RJSF expects when probing data through repeatedisValidcalls (oneOf/anyOf option resolution).- Custom-keyword extensions (e.g.
ajv-errors,ajv-merge-patch) have no ata-side counterpart yet. Schemas using these keywords will validate (ata silently ignores unknown keywords) but the extension semantics are not applied.
Contributing
See the monorepo CONTRIBUTING.md. Issues and PRs welcome on either the validator package or ata-validator itself.
