@rjsf/validator-ajv8
Advanced tools
Comparing version 5.7.1 to 5.7.2
import * as _rjsf_utils from '@rjsf/utils'; | ||
import { StrictRJSFSchema, RJSFSchema, FormContextType, ValidatorType } from '@rjsf/utils'; | ||
import Ajv, { Options, ErrorObject, ValidateFunction } from 'ajv'; | ||
import Ajv, { Options, ErrorObject } from 'ajv'; | ||
import { FormatsPluginOptions } from 'ajv-formats'; | ||
import { DataValidationCxt } from 'ajv/lib/types'; | ||
@@ -26,15 +25,18 @@ /** The type describing how to customize the AJV6 validator | ||
type Localizer = (errors?: null | ErrorObject[]) => void; | ||
/** Extend ValidateFunction to Omit its two required properties, `schema` and `schemaEnv` that are not produced by the | ||
* AJV schema standalone compilation code | ||
/** This is a simplification of the `ValidateFunction` type provided by the AJV validator down to its minimal form so | ||
* that the code still works properly with precompiled validator functions generated by the AJV standalone code | ||
* compilation but does not rely on any of the internal AJV types which causes Typescript issue for library consumers | ||
*/ | ||
interface CompiledValidateFunction<T = any> extends Omit<ValidateFunction<T>, 'schema' | 'schemaEnv'> { | ||
/** This is almost an exact copy from the `ValidateFunction` type definition from which it extends because it seems to | ||
* get lost as part of the Omit<> and this one simply returns boolean rather than `data is T`. | ||
interface CompiledValidateFunction { | ||
/** The errors produced by the precompiled validator */ | ||
errors?: null | ErrorObject[]; | ||
/** This is simplified version of a `ValidateFunction` type definition which describes the interface that our | ||
* precompiled validator will call. | ||
*/ | ||
(this: Ajv | any, data: any, dataCxt?: DataValidationCxt): boolean; | ||
(this: Ajv | any, data: any): boolean; | ||
} | ||
/** The definition of precompiled validator functions | ||
*/ | ||
type ValidatorFunctions<T = any> = { | ||
[key: string]: CompiledValidateFunction<T>; | ||
type ValidatorFunctions = { | ||
[key: string]: CompiledValidateFunction; | ||
}; | ||
@@ -63,3 +65,3 @@ | ||
*/ | ||
declare function createPrecompiledValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validateFns: ValidatorFunctions<T>, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F>; | ||
declare function createPrecompiledValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F>; | ||
@@ -66,0 +68,0 @@ declare const _default: _rjsf_utils.ValidatorType<any, _rjsf_utils.RJSFSchema, any>; |
{ | ||
"name": "@rjsf/validator-ajv8", | ||
"version": "5.7.1", | ||
"version": "5.7.2", | ||
"main": "dist/index.js", | ||
@@ -48,3 +48,3 @@ "module": "dist/validator-ajv8.esm.js", | ||
"@babel/preset-react": "^7.18.6", | ||
"@rjsf/utils": "^5.7.1", | ||
"@rjsf/utils": "^5.7.2", | ||
"@types/jest-expect-message": "^1.1.0", | ||
@@ -79,3 +79,3 @@ "@types/json-schema": "^7.0.11", | ||
"license": "Apache-2.0", | ||
"gitHead": "24f0089c70d63df7411cf558a684de1e286b713c" | ||
"gitHead": "4be621cc40425cac212a468eff0f8cb14096f82c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1536
283957