vovk-ajv 0.0.0-beta.4 → 0.0.0-beta.6

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/README.md CHANGED
@@ -7,13 +7,13 @@
7
7
  </picture>
8
8
  </a>
9
9
  <br>
10
- <strong>Back-end for Next.js (beta)</strong>
10
+ <strong>Back-end Framework for Next.js App Router</strong>
11
11
  <br />
12
- <a href="https://vovk.dev/about">About Vovk.ts</a>
13
- &nbsp;
12
+ <a href="https://vovk.dev/">Documentation</a>
13
+ &nbsp;&nbsp;
14
14
  <a href="https://vovk.dev/quick-install">Quick Start</a>
15
- &nbsp;
16
- <a href="https://github.com/finom/vovk">Github Repo</a>
15
+ &nbsp;&nbsp;
16
+ <a href="https://vovk.dev/performance">Performance</a>
17
17
  </p>
18
18
 
19
19
  ---
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Options } from 'ajv';
2
2
  import ajvLocalize from 'ajv-i18n';
3
- import { type VovkValidateOnClient } from 'vovk';
3
+ import { type VovkValidateOnClient } from 'vovk/createValidateOnClient';
4
4
  type Lang = keyof typeof ajvLocalize;
5
5
  export type VovkAjvConfig = {
6
6
  options?: Options;
package/index.js CHANGED
@@ -9,13 +9,12 @@ const _2020_1 = __importDefault(require("ajv/dist/2020"));
9
9
  const ajv_formats_1 = __importDefault(require("ajv-formats"));
10
10
  const ajv_i18n_1 = __importDefault(require("ajv-i18n"));
11
11
  const ajv_errors_1 = __importDefault(require("ajv-errors"));
12
- const vovk_1 = require("vovk");
12
+ const createValidateOnClient_1 = require("vovk/createValidateOnClient");
13
13
  const createAjv = (options, target) => {
14
14
  const AjvClass = target === 'draft-2020-12' ? _2020_1.default : ajv_1.Ajv;
15
15
  const ajv = new AjvClass({ allErrors: true, ...options });
16
16
  (0, ajv_formats_1.default)(ajv);
17
17
  (0, ajv_errors_1.default)(ajv);
18
- ajv.addKeyword('x-isDto');
19
18
  ajv.addKeyword('x-isForm');
20
19
  ajv.addKeyword('x-tsType');
21
20
  return ajv;
@@ -62,7 +61,7 @@ const validate = ({ input, schema, localize = 'en', type, endpoint, options, tar
62
61
  const isValid = ajv.validate(schema, input);
63
62
  if (!isValid) {
64
63
  ajv_i18n_1.default[localize](ajv.errors);
65
- throw new vovk_1.HttpException(vovk_1.HttpStatus.NULL, `Ajv validation failed. Invalid ${isFormData ? 'form' : type} on client: ${ajv.errorsText()}`, { input, errors: ajv.errors, endpoint });
64
+ throw new createValidateOnClient_1.HttpException(createValidateOnClient_1.HttpStatus.NULL, `Client-side validation failed. Invalid ${isFormData ? 'form' : type} on client: ${ajv.errorsText()}`, { input, errors: ajv.errors, endpoint });
66
65
  }
67
66
  }
68
67
  };
@@ -73,7 +72,7 @@ const getConfig = (schema) => {
73
72
  const target = config?.target;
74
73
  return { options, localize, target };
75
74
  };
76
- const validateOnClientAjv = (0, vovk_1.createValidateOnClient)({
75
+ const validateOnClientAjv = (0, createValidateOnClient_1.createValidateOnClient)({
77
76
  validate: (input, schema, { endpoint, type, fullSchema }) => {
78
77
  const { options, localize, target } = getConfig(fullSchema);
79
78
  validate({
@@ -87,7 +86,7 @@ const validateOnClientAjv = (0, vovk_1.createValidateOnClient)({
87
86
  });
88
87
  },
89
88
  });
90
- const configure = ({ options: givenOptions, localize: givenLocalize, target: givenTarget, }) => (0, vovk_1.createValidateOnClient)({
89
+ const configure = ({ options: givenOptions, localize: givenLocalize, target: givenTarget, }) => (0, createValidateOnClient_1.createValidateOnClient)({
91
90
  validate: (input, schema, { endpoint, type, fullSchema }) => {
92
91
  const { options, localize, target } = getConfig(fullSchema);
93
92
  validate({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vovk-ajv",
3
- "version": "0.0.0-beta.4",
4
- "description": "Local validation for JSON schemas for vovk-zod and other validation libraries for Vovk.ts",
3
+ "version": "0.0.0-beta.6",
4
+ "description": "Client-side JSON Schema validation library for Vovk.ts",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "build": "tsc",
@@ -17,17 +17,16 @@
17
17
  "vovk",
18
18
  "json",
19
19
  "ajv",
20
- "validation",
21
- "zod"
20
+ "validation"
22
21
  ],
23
22
  "author": "Andrey Gubanov",
24
23
  "license": "MIT",
25
24
  "bugs": {
26
25
  "url": "https://github.com/finom/vovk/issues"
27
26
  },
28
- "homepage": "https://github.com/finom/vovk#readme",
27
+ "homepage": "https://vovk.dev/imports",
29
28
  "peerDependencies": {
30
- "vovk": "^3.0.0-beta.36"
29
+ "vovk": "^3.0.0-beta.107"
31
30
  },
32
31
  "dependencies": {
33
32
  "ajv": "^8.17.1",