@hookform/resolvers 3.10.0 → 4.0.0
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 +74 -5
- package/ajv/dist/ajv.js +1 -1
- package/ajv/dist/ajv.js.map +1 -1
- package/ajv/dist/ajv.mjs +1 -1
- package/ajv/dist/ajv.modern.mjs +1 -1
- package/ajv/dist/ajv.modern.mjs.map +1 -1
- package/ajv/dist/ajv.module.js +1 -1
- package/ajv/dist/ajv.module.js.map +1 -1
- package/ajv/dist/ajv.umd.js +1 -1
- package/ajv/dist/ajv.umd.js.map +1 -1
- package/ajv/dist/types.d.ts +8 -0
- package/ajv/src/__tests__/__fixtures__/data-errors.ts +216 -0
- package/ajv/src/__tests__/__snapshots__/ajv-errors.ts.snap +462 -0
- package/ajv/src/__tests__/__snapshots__/ajv.ts.snap +6 -6
- package/ajv/src/__tests__/ajv-errors.ts +227 -0
- package/ajv/src/ajv.ts +27 -14
- package/ajv/src/types.ts +8 -0
- package/arktype/dist/arktype.js +1 -1
- package/arktype/dist/arktype.js.map +1 -1
- package/arktype/dist/arktype.mjs +1 -1
- package/arktype/dist/arktype.modern.mjs +1 -1
- package/arktype/dist/arktype.modern.mjs.map +1 -1
- package/arktype/dist/arktype.module.js +1 -1
- package/arktype/dist/arktype.module.js.map +1 -1
- package/arktype/dist/arktype.umd.js +1 -1
- package/arktype/dist/arktype.umd.js.map +1 -1
- package/arktype/dist/types.d.ts +1 -1
- package/arktype/package.json +1 -1
- package/arktype/src/__tests__/Form-native-validation.tsx +3 -3
- package/arktype/src/__tests__/Form.tsx +2 -2
- package/arktype/src/__tests__/__fixtures__/data.ts +1 -1
- package/arktype/src/__tests__/__snapshots__/arktype.ts.snap +22 -415
- package/arktype/src/arktype.ts +17 -6
- package/arktype/src/types.ts +1 -1
- package/class-validator/dist/class-validator.js +1 -1
- package/class-validator/dist/class-validator.js.map +1 -1
- package/class-validator/dist/class-validator.mjs +1 -1
- package/class-validator/dist/class-validator.modern.mjs +1 -1
- package/class-validator/dist/class-validator.modern.mjs.map +1 -1
- package/class-validator/dist/class-validator.module.js +1 -1
- package/class-validator/dist/class-validator.module.js.map +1 -1
- package/class-validator/dist/class-validator.umd.js +1 -1
- package/class-validator/dist/class-validator.umd.js.map +1 -1
- package/class-validator/dist/types.d.ts +1 -1
- package/class-validator/src/__tests__/class-validator.ts +1 -1
- package/class-validator/src/class-validator.ts +1 -1
- package/class-validator/src/types.ts +1 -1
- package/dist/resolvers.js +1 -1
- package/dist/resolvers.js.map +1 -1
- package/dist/resolvers.mjs +1 -1
- package/dist/resolvers.mjs.map +1 -1
- package/dist/resolvers.module.js +1 -1
- package/dist/resolvers.module.js.map +1 -1
- package/dist/resolvers.umd.js +1 -1
- package/dist/resolvers.umd.js.map +1 -1
- package/effect-ts/dist/effect-ts.js +1 -1
- package/effect-ts/dist/effect-ts.js.map +1 -1
- package/effect-ts/dist/effect-ts.mjs +1 -1
- package/effect-ts/dist/effect-ts.modern.mjs +1 -1
- package/effect-ts/dist/effect-ts.modern.mjs.map +1 -1
- package/effect-ts/dist/effect-ts.module.js +1 -1
- package/effect-ts/dist/effect-ts.module.js.map +1 -1
- package/effect-ts/dist/effect-ts.umd.js +1 -1
- package/effect-ts/dist/effect-ts.umd.js.map +1 -1
- package/effect-ts/src/__tests__/__snapshots__/effect-ts.ts.snap +35 -1
- package/effect-ts/src/__tests__/effect-ts.ts +61 -0
- package/effect-ts/src/effect-ts.ts +31 -6
- package/io-ts/dist/io-ts.js +1 -1
- package/io-ts/dist/io-ts.js.map +1 -1
- package/io-ts/dist/io-ts.mjs +1 -1
- package/io-ts/dist/io-ts.modern.mjs +1 -1
- package/io-ts/dist/io-ts.modern.mjs.map +1 -1
- package/io-ts/dist/io-ts.module.js +1 -1
- package/io-ts/dist/io-ts.module.js.map +1 -1
- package/io-ts/dist/io-ts.umd.js +1 -1
- package/io-ts/dist/io-ts.umd.js.map +1 -1
- package/package.json +46 -34
- package/standard-schema/dist/index.d.ts +2 -0
- package/standard-schema/dist/standard-schema.d.ts +2 -0
- package/standard-schema/dist/standard-schema.js +2 -0
- package/standard-schema/dist/standard-schema.js.map +1 -0
- package/standard-schema/dist/standard-schema.mjs +2 -0
- package/standard-schema/dist/standard-schema.modern.mjs +2 -0
- package/standard-schema/dist/standard-schema.modern.mjs.map +1 -0
- package/standard-schema/dist/standard-schema.module.js +2 -0
- package/standard-schema/dist/standard-schema.module.js.map +1 -0
- package/standard-schema/dist/standard-schema.umd.js +2 -0
- package/standard-schema/dist/standard-schema.umd.js.map +1 -0
- package/standard-schema/dist/types.d.ts +3 -0
- package/standard-schema/package.json +18 -0
- package/standard-schema/src/__tests__/Form-native-validation.tsx +82 -0
- package/standard-schema/src/__tests__/Form.tsx +56 -0
- package/standard-schema/src/__tests__/__fixtures__/data.ts +65 -0
- package/standard-schema/src/__tests__/__snapshots__/standard-schema.ts.snap +63 -0
- package/standard-schema/src/__tests__/standard-schema.ts +28 -0
- package/standard-schema/src/index.ts +2 -0
- package/standard-schema/src/standard-schema.ts +45 -0
- package/standard-schema/src/types.ts +10 -0
- package/superstruct/dist/superstruct.js +1 -1
- package/superstruct/dist/superstruct.js.map +1 -1
- package/superstruct/dist/superstruct.mjs +1 -1
- package/superstruct/dist/superstruct.modern.mjs +1 -1
- package/superstruct/dist/superstruct.modern.mjs.map +1 -1
- package/superstruct/dist/superstruct.module.js +1 -1
- package/superstruct/dist/superstruct.module.js.map +1 -1
- package/superstruct/dist/superstruct.umd.js +1 -1
- package/superstruct/dist/superstruct.umd.js.map +1 -1
- package/superstruct/src/superstruct.ts +1 -1
- package/typebox/src/__tests__/__snapshots__/typebox-compiler.ts.snap +21 -21
- package/typebox/src/__tests__/__snapshots__/typebox.ts.snap +21 -21
- package/typeschema/dist/typeschema.js +1 -1
- package/typeschema/dist/typeschema.js.map +1 -1
- package/typeschema/dist/typeschema.mjs +1 -1
- package/typeschema/dist/typeschema.modern.mjs +1 -1
- package/typeschema/dist/typeschema.modern.mjs.map +1 -1
- package/typeschema/dist/typeschema.module.js +1 -1
- package/typeschema/dist/typeschema.module.js.map +1 -1
- package/typeschema/dist/typeschema.umd.js +1 -1
- package/typeschema/dist/typeschema.umd.js.map +1 -1
- package/typeschema/src/typeschema.ts +3 -1
- package/valibot/dist/valibot.js +1 -1
- package/valibot/dist/valibot.js.map +1 -1
- package/valibot/dist/valibot.mjs +1 -1
- package/valibot/dist/valibot.modern.mjs +1 -1
- package/valibot/dist/valibot.modern.mjs.map +1 -1
- package/valibot/dist/valibot.module.js +1 -1
- package/valibot/dist/valibot.module.js.map +1 -1
- package/valibot/dist/valibot.umd.js +1 -1
- package/valibot/dist/valibot.umd.js.map +1 -1
- package/valibot/package.json +1 -1
- package/valibot/src/__tests__/valibot.ts +1 -1
- package/valibot/src/valibot.ts +3 -1
- package/vine/dist/vine.js +1 -1
- package/vine/dist/vine.js.map +1 -1
- package/vine/dist/vine.mjs +1 -1
- package/vine/dist/vine.modern.mjs +1 -1
- package/vine/dist/vine.modern.mjs.map +1 -1
- package/vine/dist/vine.module.js +1 -1
- package/vine/dist/vine.module.js.map +1 -1
- package/vine/dist/vine.umd.js +1 -1
- package/vine/dist/vine.umd.js.map +1 -1
- package/vine/src/vine.ts +1 -1
- package/yup/dist/yup.js +1 -1
- package/yup/dist/yup.js.map +1 -1
- package/yup/dist/yup.mjs +1 -1
- package/yup/dist/yup.modern.mjs +1 -1
- package/yup/dist/yup.modern.mjs.map +1 -1
- package/yup/dist/yup.module.js +1 -1
- package/yup/dist/yup.module.js.map +1 -1
- package/yup/dist/yup.umd.js +1 -1
- package/yup/dist/yup.umd.js.map +1 -1
- package/yup/src/yup.ts +1 -1
- package/zod/dist/zod.js +1 -1
- package/zod/dist/zod.js.map +1 -1
- package/zod/dist/zod.mjs +1 -1
- package/zod/dist/zod.modern.mjs +1 -1
- package/zod/dist/zod.modern.mjs.map +1 -1
- package/zod/dist/zod.module.js +1 -1
- package/zod/dist/zod.module.js.map +1 -1
- package/zod/dist/zod.umd.js +1 -1
- package/zod/dist/zod.umd.js.map +1 -1
- package/zod/src/zod.ts +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type } from 'arktype';
|
|
2
|
+
import { Field, InternalFieldName } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
export const schema = type({
|
|
5
|
+
username: 'string>2',
|
|
6
|
+
password: '/.*[A-Za-z].*/>8|/.*\\d.*/',
|
|
7
|
+
repeatPassword: 'string>1',
|
|
8
|
+
accessToken: 'string|number',
|
|
9
|
+
birthYear: '1900<number<2013',
|
|
10
|
+
email: 'string.email',
|
|
11
|
+
tags: 'string[]',
|
|
12
|
+
enabled: 'boolean',
|
|
13
|
+
url: 'string>1',
|
|
14
|
+
'like?': type({
|
|
15
|
+
id: 'number',
|
|
16
|
+
name: 'string>3',
|
|
17
|
+
}).array(),
|
|
18
|
+
dateStr: 'Date',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const validData: typeof schema.infer = {
|
|
22
|
+
username: 'Doe',
|
|
23
|
+
password: 'Password123_',
|
|
24
|
+
repeatPassword: 'Password123_',
|
|
25
|
+
birthYear: 2000,
|
|
26
|
+
email: 'john@doe.com',
|
|
27
|
+
tags: ['tag1', 'tag2'],
|
|
28
|
+
enabled: true,
|
|
29
|
+
accessToken: 'accessToken',
|
|
30
|
+
url: 'https://react-hook-form.com/',
|
|
31
|
+
like: [
|
|
32
|
+
{
|
|
33
|
+
id: 1,
|
|
34
|
+
name: 'name',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
dateStr: new Date('2020-01-01'),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const invalidData = {
|
|
41
|
+
password: '___',
|
|
42
|
+
email: '',
|
|
43
|
+
birthYear: 'birthYear',
|
|
44
|
+
like: [{ id: 'z' }],
|
|
45
|
+
url: 'abc',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const fields: Record<InternalFieldName, Field['_f']> = {
|
|
49
|
+
username: {
|
|
50
|
+
ref: { name: 'username' },
|
|
51
|
+
name: 'username',
|
|
52
|
+
},
|
|
53
|
+
password: {
|
|
54
|
+
ref: { name: 'password' },
|
|
55
|
+
name: 'password',
|
|
56
|
+
},
|
|
57
|
+
email: {
|
|
58
|
+
ref: { name: 'email' },
|
|
59
|
+
name: 'email',
|
|
60
|
+
},
|
|
61
|
+
birthday: {
|
|
62
|
+
ref: { name: 'birthday' },
|
|
63
|
+
name: 'birthday',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`standardSchemaResolver > should return a single error from standardSchemaResolver when validation fails 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"errors": {
|
|
6
|
+
"accessToken": {
|
|
7
|
+
"message": "accessToken must be a number or a string (was missing)",
|
|
8
|
+
"ref": undefined,
|
|
9
|
+
},
|
|
10
|
+
"birthYear": {
|
|
11
|
+
"message": "birthYear must be a number (was a string)",
|
|
12
|
+
"ref": undefined,
|
|
13
|
+
},
|
|
14
|
+
"dateStr": {
|
|
15
|
+
"message": "dateStr must be a Date (was missing)",
|
|
16
|
+
"ref": undefined,
|
|
17
|
+
},
|
|
18
|
+
"email": {
|
|
19
|
+
"message": "email must be an email address (was "")",
|
|
20
|
+
"ref": {
|
|
21
|
+
"name": "email",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
"enabled": {
|
|
25
|
+
"message": "enabled must be boolean (was missing)",
|
|
26
|
+
"ref": undefined,
|
|
27
|
+
},
|
|
28
|
+
"like": [
|
|
29
|
+
{
|
|
30
|
+
"id": {
|
|
31
|
+
"message": "like[0].id must be a number (was a string)",
|
|
32
|
+
"ref": undefined,
|
|
33
|
+
},
|
|
34
|
+
"name": {
|
|
35
|
+
"message": "like[0].name must be a string (was missing)",
|
|
36
|
+
"ref": undefined,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
"password": {
|
|
41
|
+
"message": "password must be matched by .*[A-Za-z].* or matched by .*\\d.* (was "___")",
|
|
42
|
+
"ref": {
|
|
43
|
+
"name": "password",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
"repeatPassword": {
|
|
47
|
+
"message": "repeatPassword must be a string (was missing)",
|
|
48
|
+
"ref": undefined,
|
|
49
|
+
},
|
|
50
|
+
"tags": {
|
|
51
|
+
"message": "tags must be an array (was missing)",
|
|
52
|
+
"ref": undefined,
|
|
53
|
+
},
|
|
54
|
+
"username": {
|
|
55
|
+
"message": "username must be a string (was missing)",
|
|
56
|
+
"ref": {
|
|
57
|
+
"name": "username",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
"values": {},
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { standardSchemaResolver } from '..';
|
|
2
|
+
import { fields, invalidData, schema, validData } from './__fixtures__/data';
|
|
3
|
+
|
|
4
|
+
const shouldUseNativeValidation = false;
|
|
5
|
+
|
|
6
|
+
describe('standardSchemaResolver', () => {
|
|
7
|
+
it('should return values from standardSchemaResolver when validation pass & raw=true', async () => {
|
|
8
|
+
const result = await standardSchemaResolver(schema)(validData, undefined, {
|
|
9
|
+
fields,
|
|
10
|
+
shouldUseNativeValidation,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
expect(result).toEqual({ errors: {}, values: validData });
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should return a single error from standardSchemaResolver when validation fails', async () => {
|
|
17
|
+
const result = await standardSchemaResolver(schema)(
|
|
18
|
+
invalidData,
|
|
19
|
+
undefined,
|
|
20
|
+
{
|
|
21
|
+
fields,
|
|
22
|
+
shouldUseNativeValidation,
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
expect(result).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
|
|
2
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
+
import { FieldError } from 'react-hook-form';
|
|
4
|
+
import type { Resolver } from './types';
|
|
5
|
+
|
|
6
|
+
const parseIssues = (issues: readonly StandardSchemaV1.Issue[]) => {
|
|
7
|
+
const errors: Record<string, FieldError> = {};
|
|
8
|
+
|
|
9
|
+
for (let i = 0; i < issues.length; i++) {
|
|
10
|
+
const issue = issues[i];
|
|
11
|
+
const path = issue.path?.join('.') ?? '';
|
|
12
|
+
|
|
13
|
+
if (path) {
|
|
14
|
+
if (!errors[path]) {
|
|
15
|
+
errors[path] = { message: issue.message } as FieldError;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return errors;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const standardSchemaResolver: Resolver =
|
|
24
|
+
(schema) => async (values, _, options) => {
|
|
25
|
+
let result = schema['~standard'].validate(values);
|
|
26
|
+
if (result instanceof Promise) {
|
|
27
|
+
result = await result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (result.issues) {
|
|
31
|
+
const errors = parseIssues(result.issues);
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
values: {},
|
|
35
|
+
errors: toNestErrors(errors, options),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
options.shouldUseNativeValidation && validateFieldsNatively({}, options);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
values: values,
|
|
43
|
+
errors: {},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
export type Resolver = <T extends StandardSchemaV1<any, any>>(
|
|
5
|
+
schema: T,
|
|
6
|
+
) => <TFieldValues extends FieldValues, TContext>(
|
|
7
|
+
values: TFieldValues,
|
|
8
|
+
context: TContext | undefined,
|
|
9
|
+
options: ResolverOptions<TFieldValues>,
|
|
10
|
+
) => Promise<ResolverResult<TFieldValues>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=require("@hookform/resolvers"),r=require("superstruct");exports.superstructResolver=function(s,t,a){return void 0===a&&(a={}),function(o,u,i){var l
|
|
1
|
+
var e=require("@hookform/resolvers"),r=require("superstruct");exports.superstructResolver=function(s,t,a){return void 0===a&&(a={}),function(o,u,i){var n,l=r.validate(o,s,t);return l[0]?{values:{},errors:e.toNestErrors((n=l[0],n.failures().reduce(function(e,r){return(e[r.path.join(".")]={message:r.message,type:r.type})&&e},{})),i)}:(i.shouldUseNativeValidation&&e.validateFieldsNatively({},i),{values:a.raw?Object.assign({},o):l[1],errors:{}})}};
|
|
2
2
|
//# sourceMappingURL=superstruct.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"superstruct.js","sources":["../src/superstruct.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\n\nimport { StructError, validate } from 'superstruct';\nimport { Resolver } from './types';\n\nconst parseErrorSchema = (error: StructError) =>\n error.failures().reduce<Record<string, FieldError>>(\n (previous, error) =>\n (previous[error.path.join('.')] = {\n message: error.message,\n type: error.type,\n }) && previous,\n {},\n );\n\nexport const superstructResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n (values, _, options) => {\n const result = validate(values, schema, schemaOptions);\n\n if (result[0]) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(result[0]), options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? values : result[1],\n errors: {},\n };\n };\n"],"names":["schema","schemaOptions","resolverOptions","values","_","options","error","result","validate","errors","toNestErrors","failures","reduce","previous","path","join","message","type","shouldUseNativeValidation","validateFieldsNatively","raw"],"mappings":"0FAiBE,SAACA,EAAQC,EAAeC,
|
|
1
|
+
{"version":3,"file":"superstruct.js","sources":["../src/superstruct.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\n\nimport { StructError, validate } from 'superstruct';\nimport { Resolver } from './types';\n\nconst parseErrorSchema = (error: StructError) =>\n error.failures().reduce<Record<string, FieldError>>(\n (previous, error) =>\n (previous[error.path.join('.')] = {\n message: error.message,\n type: error.type,\n }) && previous,\n {},\n );\n\nexport const superstructResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n (values, _, options) => {\n const result = validate(values, schema, schemaOptions);\n\n if (result[0]) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(result[0]), options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result[1],\n errors: {},\n };\n };\n"],"names":["schema","schemaOptions","resolverOptions","values","_","options","error","result","validate","errors","toNestErrors","failures","reduce","previous","path","join","message","type","shouldUseNativeValidation","validateFieldsNatively","raw","Object","assign"],"mappings":"0FAiBE,SAACA,EAAQC,EAAeC,GAAoB,gBAApBA,IAAAA,EAAkB,CAAE,GAC3CC,SAAAA,EAAQC,EAAGC,GACV,IAbsBC,EAahBC,EAASC,EAAAA,SAASL,EAAQH,EAAQC,GAExC,OAAIM,EAAO,GACF,CACLJ,OAAQ,GACRM,OAAQC,EAAAA,cAlBUJ,EAkBoBC,EAAO,GAjBnDD,EAAMK,WAAWC,OACf,SAACC,EAAUP,GAAK,OACbO,EAASP,EAAMQ,KAAKC,KAAK,MAAQ,CAChCC,QAASV,EAAMU,QACfC,KAAMX,EAAMW,QACRJ,CAAQ,EAChB,KAWsDR,KAItDA,EAAQa,2BAA6BC,EAAsBA,uBAAC,CAAE,EAAEd,GAEzD,CACLF,OAAQD,EAAgBkB,IAAMC,OAAOC,OAAO,CAAE,EAAEnB,GAAUI,EAAO,GACjEE,OAAQ,CAAA,GAEZ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{validate as o}from"superstruct";var
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{validate as o}from"superstruct";var s=function(s,t,a){return void 0===a&&(a={}),function(u,i,n){var f,m=o(u,s,t);return m[0]?{values:{},errors:r((f=m[0],f.failures().reduce(function(r,e){return(r[e.path.join(".")]={message:e.message,type:e.type})&&r},{})),n)}:(n.shouldUseNativeValidation&&e({},n),{values:a.raw?Object.assign({},u):m[1],errors:{}})}};export{s as superstructResolver};
|
|
2
2
|
//# sourceMappingURL=superstruct.module.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{validate as s}from"superstruct";const o=(o,t,a={})=>(u,
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{validate as s}from"superstruct";const o=(o,t,a={})=>(i,u,m)=>{const p=s(i,o,t);return p[0]?{values:{},errors:r((l=p[0],l.failures().reduce((r,e)=>(r[e.path.join(".")]={message:e.message,type:e.type})&&r,{})),m)}:(m.shouldUseNativeValidation&&e({},m),{values:a.raw?Object.assign({},i):p[1],errors:{}});var l};export{o as superstructResolver};
|
|
2
2
|
//# sourceMappingURL=superstruct.modern.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"superstruct.modern.mjs","sources":["../src/superstruct.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\n\nimport { StructError, validate } from 'superstruct';\nimport { Resolver } from './types';\n\nconst parseErrorSchema = (error: StructError) =>\n error.failures().reduce<Record<string, FieldError>>(\n (previous, error) =>\n (previous[error.path.join('.')] = {\n message: error.message,\n type: error.type,\n }) && previous,\n {},\n );\n\nexport const superstructResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n (values, _, options) => {\n const result = validate(values, schema, schemaOptions);\n\n if (result[0]) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(result[0]), options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? values : result[1],\n errors: {},\n };\n };\n"],"names":["superstructResolver","schema","schemaOptions","resolverOptions","values","_","options","result","validate","errors","toNestErrors","error","failures","reduce","previous","path","join","message","type","shouldUseNativeValidation","validateFieldsNatively","raw"],"mappings":"sHAMA,MAUaA,EACXA,CAACC,EAAQC,EAAeC,EAAkB,
|
|
1
|
+
{"version":3,"file":"superstruct.modern.mjs","sources":["../src/superstruct.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\n\nimport { StructError, validate } from 'superstruct';\nimport { Resolver } from './types';\n\nconst parseErrorSchema = (error: StructError) =>\n error.failures().reduce<Record<string, FieldError>>(\n (previous, error) =>\n (previous[error.path.join('.')] = {\n message: error.message,\n type: error.type,\n }) && previous,\n {},\n );\n\nexport const superstructResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n (values, _, options) => {\n const result = validate(values, schema, schemaOptions);\n\n if (result[0]) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(result[0]), options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result[1],\n errors: {},\n };\n };\n"],"names":["superstructResolver","schema","schemaOptions","resolverOptions","values","_","options","result","validate","errors","toNestErrors","error","failures","reduce","previous","path","join","message","type","shouldUseNativeValidation","validateFieldsNatively","raw","Object","assign"],"mappings":"sHAMA,MAUaA,EACXA,CAACC,EAAQC,EAAeC,EAAkB,CAAA,IAC1C,CAACC,EAAQC,EAAGC,KACV,MAAMC,EAASC,EAASJ,EAAQH,EAAQC,GAExC,OAAIK,EAAO,GACF,CACLH,OAAQ,CAAA,EACRK,OAAQC,GAlBUC,EAkBoBJ,EAAO,GAjBnDI,EAAMC,WAAWC,OACf,CAACC,EAAUH,KACRG,EAASH,EAAMI,KAAKC,KAAK,MAAQ,CAChCC,QAASN,EAAMM,QACfC,KAAMP,EAAMO,QACRJ,EACR,CAAA,IAWsDR,KAItDA,EAAQa,2BAA6BC,EAAuB,GAAId,GAEzD,CACLF,OAAQD,EAAgBkB,IAAMC,OAAOC,OAAO,CAAE,EAAEnB,GAAUG,EAAO,GACjEE,OAAQ,KA1BYE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{validate as o}from"superstruct";var
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{validate as o}from"superstruct";var s=function(s,t,a){return void 0===a&&(a={}),function(u,i,n){var f,m=o(u,s,t);return m[0]?{values:{},errors:r((f=m[0],f.failures().reduce(function(r,e){return(r[e.path.join(".")]={message:e.message,type:e.type})&&r},{})),n)}:(n.shouldUseNativeValidation&&e({},n),{values:a.raw?Object.assign({},u):m[1],errors:{}})}};export{s as superstructResolver};
|
|
2
2
|
//# sourceMappingURL=superstruct.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"superstruct.module.js","sources":["../src/superstruct.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\n\nimport { StructError, validate } from 'superstruct';\nimport { Resolver } from './types';\n\nconst parseErrorSchema = (error: StructError) =>\n error.failures().reduce<Record<string, FieldError>>(\n (previous, error) =>\n (previous[error.path.join('.')] = {\n message: error.message,\n type: error.type,\n }) && previous,\n {},\n );\n\nexport const superstructResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n (values, _, options) => {\n const result = validate(values, schema, schemaOptions);\n\n if (result[0]) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(result[0]), options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? values : result[1],\n errors: {},\n };\n };\n"],"names":["superstructResolver","schema","schemaOptions","resolverOptions","values","_","options","error","result","validate","errors","toNestErrors","failures","reduce","previous","path","join","message","type","shouldUseNativeValidation","validateFieldsNatively","raw"],"mappings":"sHAMA,IAUaA,EACX,SAACC,EAAQC,EAAeC,
|
|
1
|
+
{"version":3,"file":"superstruct.module.js","sources":["../src/superstruct.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\n\nimport { StructError, validate } from 'superstruct';\nimport { Resolver } from './types';\n\nconst parseErrorSchema = (error: StructError) =>\n error.failures().reduce<Record<string, FieldError>>(\n (previous, error) =>\n (previous[error.path.join('.')] = {\n message: error.message,\n type: error.type,\n }) && previous,\n {},\n );\n\nexport const superstructResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n (values, _, options) => {\n const result = validate(values, schema, schemaOptions);\n\n if (result[0]) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(result[0]), options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result[1],\n errors: {},\n };\n };\n"],"names":["superstructResolver","schema","schemaOptions","resolverOptions","values","_","options","error","result","validate","errors","toNestErrors","failures","reduce","previous","path","join","message","type","shouldUseNativeValidation","validateFieldsNatively","raw","Object","assign"],"mappings":"sHAMA,IAUaA,EACX,SAACC,EAAQC,EAAeC,GAAoB,gBAApBA,IAAAA,EAAkB,CAAE,GAC3CC,SAAAA,EAAQC,EAAGC,GACV,IAbsBC,EAahBC,EAASC,EAASL,EAAQH,EAAQC,GAExC,OAAIM,EAAO,GACF,CACLJ,OAAQ,GACRM,OAAQC,GAlBUJ,EAkBoBC,EAAO,GAjBnDD,EAAMK,WAAWC,OACf,SAACC,EAAUP,GAAK,OACbO,EAASP,EAAMQ,KAAKC,KAAK,MAAQ,CAChCC,QAASV,EAAMU,QACfC,KAAMX,EAAMW,QACRJ,CAAQ,EAChB,KAWsDR,KAItDA,EAAQa,2BAA6BC,EAAuB,CAAE,EAAEd,GAEzD,CACLF,OAAQD,EAAgBkB,IAAMC,OAAOC,OAAO,CAAE,EAAEnB,GAAUI,EAAO,GACjEE,OAAQ,CAAA,GAEZ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("superstruct")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","superstruct"],r):r((e||self).hookformResolversSuperstruct={},e.hookformResolvers,e.superstruct)}(this,function(e,r,o){e.superstructResolver=function(e,s,t){return void 0===t&&(t={}),function(u,i,n){var f,
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("superstruct")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","superstruct"],r):r((e||self).hookformResolversSuperstruct={},e.hookformResolvers,e.superstruct)}(this,function(e,r,o){e.superstructResolver=function(e,s,t){return void 0===t&&(t={}),function(u,i,n){var f,a=o.validate(u,e,s);return a[0]?{values:{},errors:r.toNestErrors((f=a[0],f.failures().reduce(function(e,r){return(e[r.path.join(".")]={message:r.message,type:r.type})&&e},{})),n)}:(n.shouldUseNativeValidation&&r.validateFieldsNatively({},n),{values:t.raw?Object.assign({},u):a[1],errors:{}})}}});
|
|
2
2
|
//# sourceMappingURL=superstruct.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"superstruct.umd.js","sources":["../src/superstruct.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\n\nimport { StructError, validate } from 'superstruct';\nimport { Resolver } from './types';\n\nconst parseErrorSchema = (error: StructError) =>\n error.failures().reduce<Record<string, FieldError>>(\n (previous, error) =>\n (previous[error.path.join('.')] = {\n message: error.message,\n type: error.type,\n }) && previous,\n {},\n );\n\nexport const superstructResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n (values, _, options) => {\n const result = validate(values, schema, schemaOptions);\n\n if (result[0]) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(result[0]), options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? values : result[1],\n errors: {},\n };\n };\n"],"names":["schema","schemaOptions","resolverOptions","values","_","options","error","result","validate","errors","toNestErrors","failures","reduce","previous","path","join","message","type","shouldUseNativeValidation","validateFieldsNatively","raw"],"mappings":"4YAiBE,SAACA,EAAQC,EAAeC,
|
|
1
|
+
{"version":3,"file":"superstruct.umd.js","sources":["../src/superstruct.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\n\nimport { StructError, validate } from 'superstruct';\nimport { Resolver } from './types';\n\nconst parseErrorSchema = (error: StructError) =>\n error.failures().reduce<Record<string, FieldError>>(\n (previous, error) =>\n (previous[error.path.join('.')] = {\n message: error.message,\n type: error.type,\n }) && previous,\n {},\n );\n\nexport const superstructResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n (values, _, options) => {\n const result = validate(values, schema, schemaOptions);\n\n if (result[0]) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(result[0]), options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result[1],\n errors: {},\n };\n };\n"],"names":["schema","schemaOptions","resolverOptions","values","_","options","error","result","validate","errors","toNestErrors","failures","reduce","previous","path","join","message","type","shouldUseNativeValidation","validateFieldsNatively","raw","Object","assign"],"mappings":"4YAiBE,SAACA,EAAQC,EAAeC,GAAoB,gBAApBA,IAAAA,EAAkB,CAAE,GAC3CC,SAAAA,EAAQC,EAAGC,GACV,IAbsBC,EAahBC,EAASC,EAAAA,SAASL,EAAQH,EAAQC,GAExC,OAAIM,EAAO,GACF,CACLJ,OAAQ,GACRM,OAAQC,EAAAA,cAlBUJ,EAkBoBC,EAAO,GAjBnDD,EAAMK,WAAWC,OACf,SAACC,EAAUP,GAAK,OACbO,EAASP,EAAMQ,KAAKC,KAAK,MAAQ,CAChCC,QAASV,EAAMU,QACfC,KAAMX,EAAMW,QACRJ,CAAQ,EAChB,KAWsDR,KAItDA,EAAQa,2BAA6BC,EAAsBA,uBAAC,CAAE,EAAEd,GAEzD,CACLF,OAAQD,EAAgBkB,IAAMC,OAAOC,OAAO,CAAE,EAAEnB,GAAUI,EAAO,GACjEE,OAAQ,CAAA,GAEZ,CAAC"}
|
|
@@ -29,7 +29,7 @@ export const superstructResolver: Resolver =
|
|
|
29
29
|
options.shouldUseNativeValidation && validateFieldsNatively({}, options);
|
|
30
30
|
|
|
31
31
|
return {
|
|
32
|
-
values: resolverOptions.raw ? values : result[1],
|
|
32
|
+
values: resolverOptions.raw ? Object.assign({}, values) : result[1],
|
|
33
33
|
errors: {},
|
|
34
34
|
};
|
|
35
35
|
};
|
|
@@ -4,7 +4,7 @@ exports[`typeboxResolver (with compiler) > should return a single error from typ
|
|
|
4
4
|
{
|
|
5
5
|
"errors": {
|
|
6
6
|
"accessToken": {
|
|
7
|
-
"message": "
|
|
7
|
+
"message": "Expected required property",
|
|
8
8
|
"ref": undefined,
|
|
9
9
|
"type": "45",
|
|
10
10
|
},
|
|
@@ -14,7 +14,7 @@ exports[`typeboxResolver (with compiler) > should return a single error from typ
|
|
|
14
14
|
"type": "41",
|
|
15
15
|
},
|
|
16
16
|
"dateStr": {
|
|
17
|
-
"message": "
|
|
17
|
+
"message": "Expected required property",
|
|
18
18
|
"ref": undefined,
|
|
19
19
|
"type": "45",
|
|
20
20
|
},
|
|
@@ -26,7 +26,7 @@ exports[`typeboxResolver (with compiler) > should return a single error from typ
|
|
|
26
26
|
"type": "48",
|
|
27
27
|
},
|
|
28
28
|
"enabled": {
|
|
29
|
-
"message": "
|
|
29
|
+
"message": "Expected required property",
|
|
30
30
|
"ref": undefined,
|
|
31
31
|
"type": "45",
|
|
32
32
|
},
|
|
@@ -38,7 +38,7 @@ exports[`typeboxResolver (with compiler) > should return a single error from typ
|
|
|
38
38
|
"type": "41",
|
|
39
39
|
},
|
|
40
40
|
"name": {
|
|
41
|
-
"message": "
|
|
41
|
+
"message": "Expected required property",
|
|
42
42
|
"ref": undefined,
|
|
43
43
|
"type": "45",
|
|
44
44
|
},
|
|
@@ -52,17 +52,17 @@ exports[`typeboxResolver (with compiler) > should return a single error from typ
|
|
|
52
52
|
"type": "52",
|
|
53
53
|
},
|
|
54
54
|
"repeatPassword": {
|
|
55
|
-
"message": "
|
|
55
|
+
"message": "Expected required property",
|
|
56
56
|
"ref": undefined,
|
|
57
57
|
"type": "45",
|
|
58
58
|
},
|
|
59
59
|
"tags": {
|
|
60
|
-
"message": "
|
|
60
|
+
"message": "Expected required property",
|
|
61
61
|
"ref": undefined,
|
|
62
62
|
"type": "45",
|
|
63
63
|
},
|
|
64
64
|
"username": {
|
|
65
|
-
"message": "
|
|
65
|
+
"message": "Expected required property",
|
|
66
66
|
"ref": {
|
|
67
67
|
"name": "username",
|
|
68
68
|
},
|
|
@@ -77,11 +77,11 @@ exports[`typeboxResolver (with compiler) > should return all the errors from typ
|
|
|
77
77
|
{
|
|
78
78
|
"errors": {
|
|
79
79
|
"accessToken": {
|
|
80
|
-
"message": "
|
|
80
|
+
"message": "Expected required property",
|
|
81
81
|
"ref": undefined,
|
|
82
82
|
"type": "45",
|
|
83
83
|
"types": {
|
|
84
|
-
"45": "
|
|
84
|
+
"45": "Expected required property",
|
|
85
85
|
"62": "Expected union value",
|
|
86
86
|
},
|
|
87
87
|
},
|
|
@@ -94,12 +94,12 @@ exports[`typeboxResolver (with compiler) > should return all the errors from typ
|
|
|
94
94
|
},
|
|
95
95
|
},
|
|
96
96
|
"dateStr": {
|
|
97
|
-
"message": "
|
|
97
|
+
"message": "Expected required property",
|
|
98
98
|
"ref": undefined,
|
|
99
99
|
"type": "45",
|
|
100
100
|
"types": {
|
|
101
101
|
"20": "Expected Date",
|
|
102
|
-
"45": "
|
|
102
|
+
"45": "Expected required property",
|
|
103
103
|
},
|
|
104
104
|
},
|
|
105
105
|
"email": {
|
|
@@ -113,12 +113,12 @@ exports[`typeboxResolver (with compiler) > should return all the errors from typ
|
|
|
113
113
|
},
|
|
114
114
|
},
|
|
115
115
|
"enabled": {
|
|
116
|
-
"message": "
|
|
116
|
+
"message": "Expected required property",
|
|
117
117
|
"ref": undefined,
|
|
118
118
|
"type": "45",
|
|
119
119
|
"types": {
|
|
120
120
|
"14": "Expected boolean",
|
|
121
|
-
"45": "
|
|
121
|
+
"45": "Expected required property",
|
|
122
122
|
},
|
|
123
123
|
},
|
|
124
124
|
"like": [
|
|
@@ -132,11 +132,11 @@ exports[`typeboxResolver (with compiler) > should return all the errors from typ
|
|
|
132
132
|
},
|
|
133
133
|
},
|
|
134
134
|
"name": {
|
|
135
|
-
"message": "
|
|
135
|
+
"message": "Expected required property",
|
|
136
136
|
"ref": undefined,
|
|
137
137
|
"type": "45",
|
|
138
138
|
"types": {
|
|
139
|
-
"45": "
|
|
139
|
+
"45": "Expected required property",
|
|
140
140
|
"54": "Expected string",
|
|
141
141
|
},
|
|
142
142
|
},
|
|
@@ -154,31 +154,31 @@ exports[`typeboxResolver (with compiler) > should return all the errors from typ
|
|
|
154
154
|
},
|
|
155
155
|
},
|
|
156
156
|
"repeatPassword": {
|
|
157
|
-
"message": "
|
|
157
|
+
"message": "Expected required property",
|
|
158
158
|
"ref": undefined,
|
|
159
159
|
"type": "45",
|
|
160
160
|
"types": {
|
|
161
|
-
"45": "
|
|
161
|
+
"45": "Expected required property",
|
|
162
162
|
"54": "Expected string",
|
|
163
163
|
},
|
|
164
164
|
},
|
|
165
165
|
"tags": {
|
|
166
|
-
"message": "
|
|
166
|
+
"message": "Expected required property",
|
|
167
167
|
"ref": undefined,
|
|
168
168
|
"type": "45",
|
|
169
169
|
"types": {
|
|
170
|
-
"45": "
|
|
170
|
+
"45": "Expected required property",
|
|
171
171
|
"6": "Expected array",
|
|
172
172
|
},
|
|
173
173
|
},
|
|
174
174
|
"username": {
|
|
175
|
-
"message": "
|
|
175
|
+
"message": "Expected required property",
|
|
176
176
|
"ref": {
|
|
177
177
|
"name": "username",
|
|
178
178
|
},
|
|
179
179
|
"type": "45",
|
|
180
180
|
"types": {
|
|
181
|
-
"45": "
|
|
181
|
+
"45": "Expected required property",
|
|
182
182
|
"54": "Expected string",
|
|
183
183
|
},
|
|
184
184
|
},
|
|
@@ -4,7 +4,7 @@ exports[`typeboxResolver > should return a single error from typeboxResolver whe
|
|
|
4
4
|
{
|
|
5
5
|
"errors": {
|
|
6
6
|
"accessToken": {
|
|
7
|
-
"message": "
|
|
7
|
+
"message": "Expected required property",
|
|
8
8
|
"ref": undefined,
|
|
9
9
|
"type": "45",
|
|
10
10
|
},
|
|
@@ -14,7 +14,7 @@ exports[`typeboxResolver > should return a single error from typeboxResolver whe
|
|
|
14
14
|
"type": "41",
|
|
15
15
|
},
|
|
16
16
|
"dateStr": {
|
|
17
|
-
"message": "
|
|
17
|
+
"message": "Expected required property",
|
|
18
18
|
"ref": undefined,
|
|
19
19
|
"type": "45",
|
|
20
20
|
},
|
|
@@ -26,7 +26,7 @@ exports[`typeboxResolver > should return a single error from typeboxResolver whe
|
|
|
26
26
|
"type": "48",
|
|
27
27
|
},
|
|
28
28
|
"enabled": {
|
|
29
|
-
"message": "
|
|
29
|
+
"message": "Expected required property",
|
|
30
30
|
"ref": undefined,
|
|
31
31
|
"type": "45",
|
|
32
32
|
},
|
|
@@ -38,7 +38,7 @@ exports[`typeboxResolver > should return a single error from typeboxResolver whe
|
|
|
38
38
|
"type": "41",
|
|
39
39
|
},
|
|
40
40
|
"name": {
|
|
41
|
-
"message": "
|
|
41
|
+
"message": "Expected required property",
|
|
42
42
|
"ref": undefined,
|
|
43
43
|
"type": "45",
|
|
44
44
|
},
|
|
@@ -52,17 +52,17 @@ exports[`typeboxResolver > should return a single error from typeboxResolver whe
|
|
|
52
52
|
"type": "52",
|
|
53
53
|
},
|
|
54
54
|
"repeatPassword": {
|
|
55
|
-
"message": "
|
|
55
|
+
"message": "Expected required property",
|
|
56
56
|
"ref": undefined,
|
|
57
57
|
"type": "45",
|
|
58
58
|
},
|
|
59
59
|
"tags": {
|
|
60
|
-
"message": "
|
|
60
|
+
"message": "Expected required property",
|
|
61
61
|
"ref": undefined,
|
|
62
62
|
"type": "45",
|
|
63
63
|
},
|
|
64
64
|
"username": {
|
|
65
|
-
"message": "
|
|
65
|
+
"message": "Expected required property",
|
|
66
66
|
"ref": {
|
|
67
67
|
"name": "username",
|
|
68
68
|
},
|
|
@@ -77,11 +77,11 @@ exports[`typeboxResolver > should return all the errors from typeboxResolver whe
|
|
|
77
77
|
{
|
|
78
78
|
"errors": {
|
|
79
79
|
"accessToken": {
|
|
80
|
-
"message": "
|
|
80
|
+
"message": "Expected required property",
|
|
81
81
|
"ref": undefined,
|
|
82
82
|
"type": "45",
|
|
83
83
|
"types": {
|
|
84
|
-
"45": "
|
|
84
|
+
"45": "Expected required property",
|
|
85
85
|
"62": "Expected union value",
|
|
86
86
|
},
|
|
87
87
|
},
|
|
@@ -94,12 +94,12 @@ exports[`typeboxResolver > should return all the errors from typeboxResolver whe
|
|
|
94
94
|
},
|
|
95
95
|
},
|
|
96
96
|
"dateStr": {
|
|
97
|
-
"message": "
|
|
97
|
+
"message": "Expected required property",
|
|
98
98
|
"ref": undefined,
|
|
99
99
|
"type": "45",
|
|
100
100
|
"types": {
|
|
101
101
|
"20": "Expected Date",
|
|
102
|
-
"45": "
|
|
102
|
+
"45": "Expected required property",
|
|
103
103
|
},
|
|
104
104
|
},
|
|
105
105
|
"email": {
|
|
@@ -113,12 +113,12 @@ exports[`typeboxResolver > should return all the errors from typeboxResolver whe
|
|
|
113
113
|
},
|
|
114
114
|
},
|
|
115
115
|
"enabled": {
|
|
116
|
-
"message": "
|
|
116
|
+
"message": "Expected required property",
|
|
117
117
|
"ref": undefined,
|
|
118
118
|
"type": "45",
|
|
119
119
|
"types": {
|
|
120
120
|
"14": "Expected boolean",
|
|
121
|
-
"45": "
|
|
121
|
+
"45": "Expected required property",
|
|
122
122
|
},
|
|
123
123
|
},
|
|
124
124
|
"like": [
|
|
@@ -132,11 +132,11 @@ exports[`typeboxResolver > should return all the errors from typeboxResolver whe
|
|
|
132
132
|
},
|
|
133
133
|
},
|
|
134
134
|
"name": {
|
|
135
|
-
"message": "
|
|
135
|
+
"message": "Expected required property",
|
|
136
136
|
"ref": undefined,
|
|
137
137
|
"type": "45",
|
|
138
138
|
"types": {
|
|
139
|
-
"45": "
|
|
139
|
+
"45": "Expected required property",
|
|
140
140
|
"54": "Expected string",
|
|
141
141
|
},
|
|
142
142
|
},
|
|
@@ -154,31 +154,31 @@ exports[`typeboxResolver > should return all the errors from typeboxResolver whe
|
|
|
154
154
|
},
|
|
155
155
|
},
|
|
156
156
|
"repeatPassword": {
|
|
157
|
-
"message": "
|
|
157
|
+
"message": "Expected required property",
|
|
158
158
|
"ref": undefined,
|
|
159
159
|
"type": "45",
|
|
160
160
|
"types": {
|
|
161
|
-
"45": "
|
|
161
|
+
"45": "Expected required property",
|
|
162
162
|
"54": "Expected string",
|
|
163
163
|
},
|
|
164
164
|
},
|
|
165
165
|
"tags": {
|
|
166
|
-
"message": "
|
|
166
|
+
"message": "Expected required property",
|
|
167
167
|
"ref": undefined,
|
|
168
168
|
"type": "45",
|
|
169
169
|
"types": {
|
|
170
|
-
"45": "
|
|
170
|
+
"45": "Expected required property",
|
|
171
171
|
"6": "Expected array",
|
|
172
172
|
},
|
|
173
173
|
},
|
|
174
174
|
"username": {
|
|
175
|
-
"message": "
|
|
175
|
+
"message": "Expected required property",
|
|
176
176
|
"ref": {
|
|
177
177
|
"name": "username",
|
|
178
178
|
},
|
|
179
179
|
"type": "45",
|
|
180
180
|
"types": {
|
|
181
|
-
"45": "
|
|
181
|
+
"45": "Expected required property",
|
|
182
182
|
"54": "Expected string",
|
|
183
183
|
},
|
|
184
184
|
},
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=require("@hookform/resolvers"),r=require("@typeschema/main"),s=require("react-hook-form"),a=function(e,r){for(var a={};e.length;){var t=e[0];if(t.path){var o=t.path.join(".");if(a[o]||(a[o]={message:t.message,type:""}),r){var i=a[o].types,n=i&&i[""];a[o]=s.appendErrors(o,r,a,"",n?[].concat(n,t.message):t.message)}e.shift()}}return a};exports.typeschemaResolver=function(s,t,o){return void 0===o&&(o={}),function(t,i,n){try{return Promise.resolve(r.validate(s,t)).then(function(r){return n.shouldUseNativeValidation&&e.validateFieldsNatively({},n),r.success?{errors:{},values:o.raw?t:r.data}:{values:{},errors:e.toNestErrors(a(r.issues,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)}})}catch(e){return Promise.reject(e)}}};
|
|
1
|
+
var e=require("@hookform/resolvers"),r=require("@typeschema/main"),s=require("react-hook-form"),a=function(e,r){for(var a={};e.length;){var t=e[0];if(t.path){var o=t.path.join(".");if(a[o]||(a[o]={message:t.message,type:""}),r){var i=a[o].types,n=i&&i[""];a[o]=s.appendErrors(o,r,a,"",n?[].concat(n,t.message):t.message)}e.shift()}}return a};exports.typeschemaResolver=function(s,t,o){return void 0===o&&(o={}),function(t,i,n){try{return Promise.resolve(r.validate(s,t)).then(function(r){return n.shouldUseNativeValidation&&e.validateFieldsNatively({},n),r.success?{errors:{},values:o.raw?Object.assign({},t):r.data}:{values:{},errors:e.toNestErrors(a(r.issues,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)}})}catch(e){return Promise.reject(e)}}};
|
|
2
2
|
//# sourceMappingURL=typeschema.js.map
|