Skip to main content
Version: Current (v6.6.1)

@rjsf/validator-ata APIs

@rjsf/validator-ata is an alternative to @rjsf/validator-ajv8, backed by ata-validator instead of AJV. The public surface mirrors the AJV package, so swapping the import is enough for the form to keep working: customizeValidator(), ValidatorType<T, S, F>, custom formats, transformErrors, customValidate, and suppressDuplicateFiltering all behave the same.

See the Validation documentation for examples of using these APIs.

Differences from @rjsf/validator-ajv8

  • AJV-only options (AjvClass, ajvFormatOptions, ajvOptionsOverrides) are not accepted. The closest equivalent is ataOptionsOverrides, which is spread on top of the default ata-validator options.
  • The ata-validator format set is always installed, so there is no opt-in flag for formats.
  • ata-validator's error params are frozen, so the pre-quote pass that validator-ajv8 runs for ajv-i18n is unnecessary. Localizers that mutate message in place still work as-is.
  • Precompiled validators (compileSchemaValidators / createPrecompiledValidator) are supported. ata-validator's bundleStandalone output is adapted into the validator function map the precompiled consumer expects. Error output matches the non-precompiled validator, including per-field errors for schema-valued additionalProperties (with ata-validator >= 0.17.4); an invalid anyOf reports a single error on the field, the same as the runtime path. One constraint carries over from the standalone (AOT) path: custom formats must be a RegExp or pre-anchored string pattern, since a function checker cannot be serialized into the bundle and is rejected at compile time.

Types

There are a few TypeScript types that are exported by @rjsf/validator-ata in support of the APIs. These types can be found on GitHub here.

APIs

customizeValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>()

Creates and returns a customized implementation of the ValidatorType with the given customization options if provided. If a localizer is provided, it is used to translate the messages generated by the underlying ata-validator validation.

Parameters

  • [options=]: CustomValidatorOptionsType - The optional map of CustomValidatorOptionsType options that are used to create the ValidatorType instance. Supported options:
    • additionalMetaSchemas: Additional schemas registered for cross-schema $ref resolution
    • customFormats: Custom format checkers; values can be functions, RegExps, or pre-anchored regex source strings
    • ataOptionsOverrides: Overrides spread on top of the default ata-validator options (e.g. coerceTypes, removeAdditional, verbose, abortEarly)
    • extenderFn: A function called against the constructed Validator instance for additional setup; returning a different instance is supported
    • suppressDuplicateFiltering: Controls filtering of duplicate anyOf/oneOf errors using the SuppressDuplicateFilteringType type. 'none' (default) filters duplicates for both; 'anyOf' suppresses filtering for anyOf (oneOf duplicates still filtered); 'oneOf' suppresses filtering for oneOf (anyOf duplicates still filtered); 'all' disables all duplicate filtering.
  • [localizer]: Localizer | undefined - If provided, is used to localize a list of ata-validator ValidationErrors after running the form validation

Returns

  • ValidatorType<T, S, F>: The custom validator implementation resulting from the set of parameters provided

compileSchemaValidators<S extends StrictRJSFSchema = RJSFSchema>()

Compiles a schema into an output file that can be loaded later as a precompiled validator. The main reasons for using a precompiled validator are reducing code size, improving startup time by skipping schema compilation, and avoiding dynamic code generation when a browser's Content Security Policy forbids it. Under the hood this calls ata-validator's bundleStandalone and wraps the result in the map the precompiled consumer expects.

NOTE: Custom formats passed through options.customFormats must be a RegExp or a pre-anchored string pattern. A function checker cannot be serialized into the standalone bundle and is rejected at compile time.

Parameters

  • schema: S - The schema to be compiled into a set of precompiled validator functions
  • output: string - The name of the file into which the precompiled validator functions are generated
  • [options=]: CustomValidatorOptionsType - The same CustomValidatorOptionsType options accepted by customizeValidator(), used to alter the validator that compiles the schema

createPrecompiledValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>()

Creates and returns a ValidatorType interface that is implemented with a precompiled validator. If a localizer is provided, it is used to translate the messages generated by the underlying ata-validator validation.

NOTE: The validateFns parameter is an object obtained by importing from a precompiled validation file created via the compileSchemaValidators() function.

Parameters

  • validateFns: ValidatorFunctions - The map of the validation functions that are created by the compileSchemaValidators() function
  • rootSchema: S - The root schema that was used with the compileSchemaValidators() function
  • [localizer]: Localizer | undefined - If provided, is used to localize the list of ata-validator ValidationErrors after running the form validation
  • [suppressDuplicateFiltering]: SuppressDuplicateFilteringType | undefined - Controls filtering of duplicate anyOf/oneOf errors. See customizeValidator() for the full description of each value.

Returns

  • ValidatorType<T, S, F>: The precompiled validator implementation resulting from the set of parameters provided