@rjsf/validator-ajv8 6.1.1 → 6.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compileSchemaValidators.cjs +21 -4
- package/dist/compileSchemaValidators.cjs.map +2 -2
- package/dist/compileSchemaValidators.esm.js +21 -4
- package/dist/compileSchemaValidators.esm.js.map +2 -2
- package/dist/index.cjs +32 -6
- package/dist/index.cjs.map +2 -2
- package/dist/validator-ajv8.esm.js +34 -6
- package/dist/validator-ajv8.esm.js.map +2 -2
- package/dist/validator-ajv8.umd.js +32 -6
- package/lib/compileSchemaValidatorsCode.js +2 -2
- package/lib/compileSchemaValidatorsCode.js.map +1 -1
- package/lib/createAjvInstance.d.ts +2 -1
- package/lib/createAjvInstance.js +6 -2
- package/lib/createAjvInstance.js.map +1 -1
- package/lib/processRawValidationErrors.js +26 -3
- package/lib/processRawValidationErrors.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +2 -0
- package/lib/validator.js +2 -2
- package/lib/validator.js.map +1 -1
- package/package.json +3 -3
- package/src/compileSchemaValidatorsCode.ts +16 -2
- package/src/createAjvInstance.ts +6 -1
- package/src/processRawValidationErrors.ts +26 -2
- package/src/types.ts +2 -0
- package/src/validator.ts +10 -2
package/lib/types.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface CustomValidatorOptionsType {
|
|
|
15
15
|
ajvFormatOptions?: FormatsPluginOptions | false;
|
|
16
16
|
/** The AJV class to construct */
|
|
17
17
|
AjvClass?: typeof Ajv;
|
|
18
|
+
/** A function to call to extend AJV, such as `ajvErrors()` */
|
|
19
|
+
extenderFn?: (ajv: Ajv) => Ajv;
|
|
18
20
|
}
|
|
19
21
|
/** The type describing a function that takes a list of Ajv `ErrorObject`s and localizes them
|
|
20
22
|
*/
|
package/lib/validator.js
CHANGED
|
@@ -10,8 +10,8 @@ export default class AJV8Validator {
|
|
|
10
10
|
* @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s
|
|
11
11
|
*/
|
|
12
12
|
constructor(options, localizer) {
|
|
13
|
-
const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;
|
|
14
|
-
this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);
|
|
13
|
+
const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass, extenderFn } = options;
|
|
14
|
+
this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass, extenderFn);
|
|
15
15
|
this.localizer = localizer;
|
|
16
16
|
}
|
|
17
17
|
/** Resets the internal AJV validator to clear schemas from it. Can be helpful for resetting the validator for tests.
|
package/lib/validator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,UAAU,EAGV,MAAM,EAEN,kBAAkB,EAKlB,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,0BAAuD,MAAM,8BAA8B,CAAC;AAEnG;GACG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAehC;;;;OAIG;IACH,YAAY,OAAmC,EAAE,SAAqB;QACpE,MAAM,EAAE,qBAAqB,EAAE,aAAa,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,UAAU,EAGV,MAAM,EAEN,kBAAkB,EAKlB,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,0BAAuD,MAAM,8BAA8B,CAAC;AAEnG;GACG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 -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/validator-ajv8",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"lodash-es": "^4.17.21"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@rjsf/utils": "^6.x"
|
|
86
|
+
"@rjsf/utils": "^6.2.x"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@rjsf/utils": "^6.
|
|
89
|
+
"@rjsf/utils": "^6.2.0",
|
|
90
90
|
"@types/json-schema": "^7.0.15",
|
|
91
91
|
"ajv-i18n": "^4.2.0",
|
|
92
92
|
"eslint": "^8.57.1"
|
|
@@ -21,14 +21,28 @@ export function compileSchemaValidatorsCode<S extends StrictRJSFSchema = RJSFSch
|
|
|
21
21
|
const schemaMaps = schemaParser(schema);
|
|
22
22
|
const schemas = Object.values(schemaMaps);
|
|
23
23
|
|
|
24
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
additionalMetaSchemas,
|
|
26
|
+
customFormats,
|
|
27
|
+
ajvOptionsOverrides = {},
|
|
28
|
+
ajvFormatOptions,
|
|
29
|
+
AjvClass,
|
|
30
|
+
extenderFn,
|
|
31
|
+
} = options;
|
|
25
32
|
// Allow users to turn off the `lines: true` feature in their own overrides, but NOT the `source: true`
|
|
26
33
|
const compileOptions = {
|
|
27
34
|
...ajvOptionsOverrides,
|
|
28
35
|
code: { lines: true, ...ajvOptionsOverrides.code, source: true },
|
|
29
36
|
schemas,
|
|
30
37
|
};
|
|
31
|
-
const ajv = createAjvInstance(
|
|
38
|
+
const ajv = createAjvInstance(
|
|
39
|
+
additionalMetaSchemas,
|
|
40
|
+
customFormats,
|
|
41
|
+
compileOptions,
|
|
42
|
+
ajvFormatOptions,
|
|
43
|
+
AjvClass,
|
|
44
|
+
extenderFn,
|
|
45
|
+
);
|
|
32
46
|
|
|
33
47
|
return standaloneCode(ajv);
|
|
34
48
|
}
|
package/src/createAjvInstance.ts
CHANGED
|
@@ -30,6 +30,7 @@ export const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*)
|
|
|
30
30
|
* @param [ajvOptionsOverrides={}] - The set of validator config override options
|
|
31
31
|
* @param [ajvFormatOptions] - The `ajv-format` options to use when adding formats to `ajv`; pass `false` to disable it
|
|
32
32
|
* @param [AjvClass] - The `Ajv` class to use when creating the validator instance
|
|
33
|
+
* @param [extenderFn] - A function to call to extend AJV, such as `ajvErrors()`
|
|
33
34
|
*/
|
|
34
35
|
export default function createAjvInstance(
|
|
35
36
|
additionalMetaSchemas?: CustomValidatorOptionsType['additionalMetaSchemas'],
|
|
@@ -37,8 +38,9 @@ export default function createAjvInstance(
|
|
|
37
38
|
ajvOptionsOverrides: CustomValidatorOptionsType['ajvOptionsOverrides'] = {},
|
|
38
39
|
ajvFormatOptions?: FormatsPluginOptions | false,
|
|
39
40
|
AjvClass: typeof Ajv = Ajv,
|
|
41
|
+
extenderFn?: CustomValidatorOptionsType['extenderFn'],
|
|
40
42
|
) {
|
|
41
|
-
|
|
43
|
+
let ajv = new AjvClass({ ...AJV_CONFIG, ...ajvOptionsOverrides });
|
|
42
44
|
if (ajvFormatOptions) {
|
|
43
45
|
addFormats(ajv, ajvFormatOptions);
|
|
44
46
|
} else if (ajvFormatOptions !== false) {
|
|
@@ -64,6 +66,9 @@ export default function createAjvInstance(
|
|
|
64
66
|
ajv.addFormat(formatName, customFormats[formatName]);
|
|
65
67
|
});
|
|
66
68
|
}
|
|
69
|
+
if (extenderFn) {
|
|
70
|
+
ajv = extenderFn(ajv);
|
|
71
|
+
}
|
|
67
72
|
|
|
68
73
|
return ajv;
|
|
69
74
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { ErrorObject } from 'ajv';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import {
|
|
4
|
+
ANY_OF_KEY,
|
|
4
5
|
createErrorHandler,
|
|
5
6
|
CustomValidator,
|
|
6
7
|
ErrorTransformer,
|
|
7
8
|
FormContextType,
|
|
8
9
|
getDefaultFormState,
|
|
9
10
|
getUiOptions,
|
|
11
|
+
ONE_OF_KEY,
|
|
10
12
|
PROPERTIES_KEY,
|
|
11
13
|
RJSFSchema,
|
|
12
14
|
RJSFValidationError,
|
|
@@ -34,7 +36,7 @@ export function transformRJSFValidationErrors<
|
|
|
34
36
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
35
37
|
F extends FormContextType = any,
|
|
36
38
|
>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {
|
|
37
|
-
|
|
39
|
+
const errorList = errors.map((e: ErrorObject) => {
|
|
38
40
|
const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;
|
|
39
41
|
let { message = '' } = rest;
|
|
40
42
|
let property = instancePath.replace(/\//g, '.');
|
|
@@ -105,6 +107,28 @@ export function transformRJSFValidationErrors<
|
|
|
105
107
|
title: uiTitle,
|
|
106
108
|
};
|
|
107
109
|
});
|
|
110
|
+
// Filter out duplicates around anyOf/oneOf messages
|
|
111
|
+
return errorList.reduce((acc: RJSFValidationError[], err: RJSFValidationError) => {
|
|
112
|
+
const { message, schemaPath } = err;
|
|
113
|
+
const anyOfIndex = schemaPath?.indexOf(`/${ANY_OF_KEY}/`);
|
|
114
|
+
const oneOfIndex = schemaPath?.indexOf(`/${ONE_OF_KEY}/`);
|
|
115
|
+
let schemaPrefix: string | undefined;
|
|
116
|
+
// Look specifically for `/anyOr/` or `/oneOf/` within the schemaPath information
|
|
117
|
+
if (anyOfIndex && anyOfIndex >= 0) {
|
|
118
|
+
schemaPrefix = schemaPath?.substring(0, anyOfIndex);
|
|
119
|
+
} else if (oneOfIndex && oneOfIndex >= 0) {
|
|
120
|
+
schemaPrefix = schemaPath?.substring(0, oneOfIndex);
|
|
121
|
+
}
|
|
122
|
+
// If there is a schemaPrefix, then search for a duplicate message with the same prefix, otherwise undefined
|
|
123
|
+
const dup = schemaPrefix
|
|
124
|
+
? acc.find((e: RJSFValidationError) => e.message === message && e.schemaPath?.startsWith(schemaPrefix))
|
|
125
|
+
: undefined;
|
|
126
|
+
if (!dup) {
|
|
127
|
+
// Only push an error that is not a duplicate
|
|
128
|
+
acc.push(err);
|
|
129
|
+
}
|
|
130
|
+
return acc;
|
|
131
|
+
}, [] as RJSFValidationError[]);
|
|
108
132
|
}
|
|
109
133
|
|
|
110
134
|
/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives
|
|
@@ -161,7 +185,7 @@ export default function processRawValidationErrors<
|
|
|
161
185
|
// Include form data with undefined values, which is required for custom validation.
|
|
162
186
|
const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;
|
|
163
187
|
|
|
164
|
-
const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);
|
|
188
|
+
const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema, errorSchema);
|
|
165
189
|
const userErrorSchema = unwrapErrorHandler<T>(errorHandler);
|
|
166
190
|
return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);
|
|
167
191
|
}
|
package/src/types.ts
CHANGED
|
@@ -16,6 +16,8 @@ export interface CustomValidatorOptionsType {
|
|
|
16
16
|
ajvFormatOptions?: FormatsPluginOptions | false;
|
|
17
17
|
/** The AJV class to construct */
|
|
18
18
|
AjvClass?: typeof Ajv;
|
|
19
|
+
/** A function to call to extend AJV, such as `ajvErrors()` */
|
|
20
|
+
extenderFn?: (ajv: Ajv) => Ajv;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/** The type describing a function that takes a list of Ajv `ErrorObject`s and localizes them
|
package/src/validator.ts
CHANGED
|
@@ -42,8 +42,16 @@ export default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
42
42
|
* @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s
|
|
43
43
|
*/
|
|
44
44
|
constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {
|
|
45
|
-
const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } =
|
|
46
|
-
|
|
45
|
+
const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass, extenderFn } =
|
|
46
|
+
options;
|
|
47
|
+
this.ajv = createAjvInstance(
|
|
48
|
+
additionalMetaSchemas,
|
|
49
|
+
customFormats,
|
|
50
|
+
ajvOptionsOverrides,
|
|
51
|
+
ajvFormatOptions,
|
|
52
|
+
AjvClass,
|
|
53
|
+
extenderFn,
|
|
54
|
+
);
|
|
47
55
|
this.localizer = localizer;
|
|
48
56
|
}
|
|
49
57
|
|