packages/docs/docs/api-reference/validator-ajv8.md
In RJSF version 6, the original, embedded AJV 6 validator implementation from earlier versions was removed in favor of the @rjsf/validator-ajv8 package.
@rjsf/validator-ajv8 uses the AJV 8 package, including adding support for using precompiled validators.
Below are the exported API functions that are provided by this package.
See the Validation documentation for examples of using these APIs.
There are a few Typescript types that are exported by @rjsf/validator-ajv8 in support of the APIs.
These types can be found on GitHub here.
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 AJV validation.
CustomValidatorOptionsType options that are used to create the ValidatorType instance. Supported options:
additionalMetaSchemas: Additional meta schemas the validator can accesscustomFormats: Additional custom format validatorsajvOptionsOverrides: Config overrides passed to the AJV constructorajvFormatOptions: Options for ajv-formats; pass false to disable format support entirelyAjvClass: The AJV class to construct (e.g. Ajv2019, Ajv2020)extenderFn: A function called to extend the AJV instance (e.g. ajvErrors())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.ErrorObjects after running the form validation using AJVThe function used to compile a schema into an output file in the form that allows it to be used as a precompiled validator. The main reasons for using a precompiled validator is reducing code size, improving validation speed and, most importantly, avoiding dynamic code compilation when prohibited by a browser's Content Security Policy. For more information about AJV code compilation see: https://ajv.js.org/standalone.html
CustomValidatorOptionsType information used to alter the AJV validator used for compiling the schema. They are the same options that are passed to the customizeValidator() function in order to modify the behavior of the regular AJV-based validator.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 AJV validation.
NOTE: The
validateFnsparameter is an object obtained by importing from a precompiled validation file created via thecompileSchemaValidators()function.
compileSchemaValidators() functioncompileSchemaValidators() functionErrorObjects after running the form validation using AJVSuppressDuplicateFilteringType | undefined - Controls filtering of duplicate anyOf/oneOf errors. See customizeValidator() for full description of each value.