vovk-ajv 0.0.0-draft.27 → 0.0.0-draft.28
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/index.d.ts +5 -4
- package/index.js +4 -4
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import { Options } from 'ajv';
|
|
|
2
2
|
import { type VovkValidateOnClient } from 'vovk';
|
|
3
3
|
import ajvLocalize from 'ajv-i18n';
|
|
4
4
|
type Lang = keyof typeof ajvLocalize;
|
|
5
|
+
export type VovkAjvConfig = {
|
|
6
|
+
options?: Options;
|
|
7
|
+
localize?: Lang;
|
|
8
|
+
};
|
|
5
9
|
declare const validateOnClient: VovkValidateOnClient;
|
|
6
|
-
declare const configure: ({ options: givenOptions, localize: givenLocalize
|
|
7
|
-
options: Options;
|
|
8
|
-
localize: Lang;
|
|
9
|
-
}) => VovkValidateOnClient;
|
|
10
|
+
declare const configure: ({ options: givenOptions, localize: givenLocalize }: VovkAjvConfig) => VovkValidateOnClient;
|
|
10
11
|
declare const validateOnClientAjv: typeof validateOnClient & {
|
|
11
12
|
configure: typeof configure;
|
|
12
13
|
};
|
package/index.js
CHANGED
|
@@ -31,9 +31,9 @@ const validate = ({ input, validation, ajv, localize = 'en', }) => {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
const getConfig = (fullSchema) => {
|
|
34
|
-
const config = fullSchema.config.custom;
|
|
35
|
-
const options = config?.
|
|
36
|
-
const localize = config?.
|
|
34
|
+
const config = fullSchema.config.custom?.ajv;
|
|
35
|
+
const options = config?.options || {};
|
|
36
|
+
const localize = config?.localize || 'en';
|
|
37
37
|
return { options, localize };
|
|
38
38
|
};
|
|
39
39
|
let ajvScope = null;
|
|
@@ -45,7 +45,7 @@ const validateOnClient = (input, validation, fullSchema) => {
|
|
|
45
45
|
}
|
|
46
46
|
return validate({ input, validation, ajv: ajvScope, localize });
|
|
47
47
|
};
|
|
48
|
-
const configure = ({ options: givenOptions, localize: givenLocalize
|
|
48
|
+
const configure = ({ options: givenOptions, localize: givenLocalize }) => (input, validation, fullSchema) => {
|
|
49
49
|
const { options, localize } = getConfig(fullSchema);
|
|
50
50
|
const ajv = new ajv_1.default({ ...options, ...givenOptions });
|
|
51
51
|
(0, ajv_formats_1.default)(ajv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vovk-ajv",
|
|
3
|
-
"version": "0.0.0-draft.
|
|
3
|
+
"version": "0.0.0-draft.28",
|
|
4
4
|
"description": "Local validation for JSON schemas for vovk-zod and other validation libraries for Vovk.ts",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"ajv-i18n": "^4.2.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"vovk": "^3.0.0-draft.
|
|
35
|
+
"vovk": "^3.0.0-draft.92"
|
|
36
36
|
}
|
|
37
37
|
}
|