@hookform/resolvers 3.1.1 → 3.3.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 +56 -12
- 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/src/ajv.ts +2 -2
- 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/src/arktype.ts +2 -2
- 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/src/__tests__/class-validator.ts +41 -0
- package/class-validator/src/class-validator.ts +6 -3
- package/computed-types/dist/computed-types.js +1 -1
- package/computed-types/dist/computed-types.js.map +1 -1
- package/computed-types/dist/computed-types.mjs +1 -1
- package/computed-types/dist/computed-types.modern.mjs +1 -1
- package/computed-types/dist/computed-types.modern.mjs.map +1 -1
- package/computed-types/dist/computed-types.module.js +1 -1
- package/computed-types/dist/computed-types.module.js.map +1 -1
- package/computed-types/dist/computed-types.umd.js +1 -1
- package/computed-types/dist/computed-types.umd.js.map +1 -1
- package/computed-types/src/computed-types.ts +2 -2
- package/dist/index.d.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/dist/toNestErrors.d.ts +2 -0
- 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/io-ts/src/io-ts.ts +2 -2
- package/joi/dist/joi.js +1 -1
- package/joi/dist/joi.js.map +1 -1
- package/joi/dist/joi.mjs +1 -1
- package/joi/dist/joi.modern.mjs +1 -1
- package/joi/dist/joi.modern.mjs.map +1 -1
- package/joi/dist/joi.module.js +1 -1
- package/joi/dist/joi.module.js.map +1 -1
- package/joi/dist/joi.umd.js +1 -1
- package/joi/dist/joi.umd.js.map +1 -1
- package/joi/src/joi.ts +2 -2
- package/nope/dist/nope.js +1 -1
- package/nope/dist/nope.js.map +1 -1
- package/nope/dist/nope.mjs +1 -1
- package/nope/dist/nope.modern.mjs +1 -1
- package/nope/dist/nope.modern.mjs.map +1 -1
- package/nope/dist/nope.module.js +1 -1
- package/nope/dist/nope.module.js.map +1 -1
- package/nope/dist/nope.umd.js +1 -1
- package/nope/dist/nope.umd.js.map +1 -1
- package/nope/src/nope.ts +3 -3
- package/package.json +37 -27
- 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 +2 -2
- package/typanion/dist/typanion.js +1 -1
- package/typanion/dist/typanion.js.map +1 -1
- package/typanion/dist/typanion.mjs +1 -1
- package/typanion/dist/typanion.modern.mjs +1 -1
- package/typanion/dist/typanion.modern.mjs.map +1 -1
- package/typanion/dist/typanion.module.js +1 -1
- package/typanion/dist/typanion.module.js.map +1 -1
- package/typanion/dist/typanion.umd.js +1 -1
- package/typanion/dist/typanion.umd.js.map +1 -1
- package/typanion/src/typanion.ts +2 -2
- package/typebox/dist/typebox.js +1 -1
- package/typebox/dist/typebox.js.map +1 -1
- package/typebox/dist/typebox.mjs +1 -1
- package/typebox/dist/typebox.modern.mjs +1 -1
- package/typebox/dist/typebox.modern.mjs.map +1 -1
- package/typebox/dist/typebox.module.js +1 -1
- package/typebox/dist/typebox.module.js.map +1 -1
- package/typebox/dist/typebox.umd.js +1 -1
- package/typebox/dist/typebox.umd.js.map +1 -1
- package/typebox/src/__tests__/__fixtures__/data.ts +2 -7
- package/typebox/src/__tests__/__snapshots__/typebox.ts.snap +57 -59
- package/typebox/src/typebox.ts +2 -2
- package/valibot/dist/index.d.ts +2 -0
- package/valibot/dist/types.d.ts +13 -0
- package/valibot/dist/valibot.d.ts +2 -0
- package/valibot/dist/valibot.js +2 -0
- package/valibot/dist/valibot.js.map +1 -0
- package/valibot/dist/valibot.mjs +2 -0
- package/valibot/dist/valibot.modern.mjs +2 -0
- package/valibot/dist/valibot.modern.mjs.map +1 -0
- package/valibot/dist/valibot.module.js +2 -0
- package/valibot/dist/valibot.module.js.map +1 -0
- package/valibot/dist/valibot.umd.js +2 -0
- package/valibot/dist/valibot.umd.js.map +1 -0
- package/valibot/package.json +18 -0
- package/valibot/src/__tests__/Form-native-validation.tsx +81 -0
- package/valibot/src/__tests__/Form.tsx +61 -0
- package/valibot/src/__tests__/__fixtures__/data.ts +89 -0
- package/valibot/src/__tests__/__snapshots__/valibot.ts.snap +418 -0
- package/valibot/src/__tests__/valibot.ts +101 -0
- package/valibot/src/index.ts +2 -0
- package/valibot/src/types.ts +22 -0
- package/valibot/src/valibot.ts +91 -0
- package/vest/dist/types.d.ts +4 -4
- package/vest/dist/vest.js +1 -1
- package/vest/dist/vest.js.map +1 -1
- package/vest/dist/vest.mjs +1 -1
- package/vest/dist/vest.modern.mjs +1 -1
- package/vest/dist/vest.modern.mjs.map +1 -1
- package/vest/dist/vest.module.js +1 -1
- package/vest/dist/vest.module.js.map +1 -1
- package/vest/dist/vest.umd.js +1 -1
- package/vest/dist/vest.umd.js.map +1 -1
- package/vest/src/__tests__/vest.ts +13 -0
- package/vest/src/types.ts +10 -7
- package/vest/src/vest.ts +5 -5
- package/yup/dist/yup.d.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/__tests__/yup.ts +25 -31
- package/yup/src/yup.ts +3 -3
- 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 +2 -2
- package/dist/toNestError.d.ts +0 -2
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useForm } from 'react-hook-form';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import user from '@testing-library/user-event';
|
|
5
|
+
import { string, required, object, minLength } from 'valibot';
|
|
6
|
+
import { valibotResolver } from '..';
|
|
7
|
+
|
|
8
|
+
const USERNAME_REQUIRED_MESSAGE = 'username field is required';
|
|
9
|
+
const PASSWORD_REQUIRED_MESSAGE = 'password field is required';
|
|
10
|
+
|
|
11
|
+
const schema = required(
|
|
12
|
+
object({
|
|
13
|
+
username: string(USERNAME_REQUIRED_MESSAGE, [
|
|
14
|
+
minLength(2, USERNAME_REQUIRED_MESSAGE),
|
|
15
|
+
]),
|
|
16
|
+
password: string(PASSWORD_REQUIRED_MESSAGE, [
|
|
17
|
+
minLength(2, PASSWORD_REQUIRED_MESSAGE),
|
|
18
|
+
]),
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
type FormData = { username: string; password: string };
|
|
23
|
+
|
|
24
|
+
interface Props {
|
|
25
|
+
onSubmit: (data: FormData) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function TestComponent({ onSubmit }: Props) {
|
|
29
|
+
const { register, handleSubmit } = useForm<FormData>({
|
|
30
|
+
resolver: valibotResolver(schema),
|
|
31
|
+
shouldUseNativeValidation: true,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
36
|
+
<input {...register('username')} placeholder="username" />
|
|
37
|
+
|
|
38
|
+
<input {...register('password')} placeholder="password" />
|
|
39
|
+
|
|
40
|
+
<button type="submit">submit</button>
|
|
41
|
+
</form>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
test("form's native validation with Zod", async () => {
|
|
46
|
+
const handleSubmit = vi.fn();
|
|
47
|
+
render(<TestComponent onSubmit={handleSubmit} />);
|
|
48
|
+
|
|
49
|
+
// username
|
|
50
|
+
let usernameField = screen.getByPlaceholderText(
|
|
51
|
+
/username/i,
|
|
52
|
+
) as HTMLInputElement;
|
|
53
|
+
expect(usernameField.validity.valid).toBe(true);
|
|
54
|
+
expect(usernameField.validationMessage).toBe('');
|
|
55
|
+
|
|
56
|
+
// password
|
|
57
|
+
let passwordField = screen.getByPlaceholderText(
|
|
58
|
+
/password/i,
|
|
59
|
+
) as HTMLInputElement;
|
|
60
|
+
expect(passwordField.validity.valid).toBe(true);
|
|
61
|
+
expect(passwordField.validationMessage).toBe('');
|
|
62
|
+
|
|
63
|
+
await user.click(screen.getByText(/submit/i));
|
|
64
|
+
|
|
65
|
+
// username
|
|
66
|
+
usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement;
|
|
67
|
+
expect(usernameField.validity.valid).toBe(false);
|
|
68
|
+
expect(usernameField.validationMessage).toBe(USERNAME_REQUIRED_MESSAGE);
|
|
69
|
+
|
|
70
|
+
// password
|
|
71
|
+
passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement;
|
|
72
|
+
expect(passwordField.validity.valid).toBe(false);
|
|
73
|
+
expect(passwordField.validationMessage).toBe(PASSWORD_REQUIRED_MESSAGE);
|
|
74
|
+
|
|
75
|
+
await user.type(screen.getByPlaceholderText(/password/i), 'password');
|
|
76
|
+
|
|
77
|
+
// password
|
|
78
|
+
passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement;
|
|
79
|
+
expect(passwordField.validity.valid).toBe(true);
|
|
80
|
+
expect(passwordField.validationMessage).toBe('');
|
|
81
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import user from '@testing-library/user-event';
|
|
4
|
+
import { useForm } from 'react-hook-form';
|
|
5
|
+
import { string, required, object, minLength } from 'valibot';
|
|
6
|
+
import { valibotResolver } from '..';
|
|
7
|
+
|
|
8
|
+
const USERNAME_REQUIRED_MESSAGE = 'username field is required';
|
|
9
|
+
const PASSWORD_REQUIRED_MESSAGE = 'password field is required';
|
|
10
|
+
|
|
11
|
+
const schema = required(
|
|
12
|
+
object({
|
|
13
|
+
username: string(USERNAME_REQUIRED_MESSAGE, [
|
|
14
|
+
minLength(2, USERNAME_REQUIRED_MESSAGE),
|
|
15
|
+
]),
|
|
16
|
+
password: string(PASSWORD_REQUIRED_MESSAGE, [
|
|
17
|
+
minLength(2, PASSWORD_REQUIRED_MESSAGE),
|
|
18
|
+
]),
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
type FormData = { username: string; password: string };
|
|
23
|
+
|
|
24
|
+
interface Props {
|
|
25
|
+
onSubmit: (data: FormData) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function TestComponent({ onSubmit }: Props) {
|
|
29
|
+
const {
|
|
30
|
+
register,
|
|
31
|
+
handleSubmit,
|
|
32
|
+
formState: { errors },
|
|
33
|
+
} = useForm<FormData>({
|
|
34
|
+
resolver: valibotResolver(schema), // Useful to check TypeScript regressions
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
39
|
+
<input {...register('username')} />
|
|
40
|
+
{errors.username && <span role="alert">{errors.username.message}</span>}
|
|
41
|
+
|
|
42
|
+
<input {...register('password')} />
|
|
43
|
+
{errors.password && <span role="alert">{errors.password.message}</span>}
|
|
44
|
+
|
|
45
|
+
<button type="submit">submit</button>
|
|
46
|
+
</form>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
test("form's validation with Valibot and TypeScript's integration", async () => {
|
|
51
|
+
const handleSubmit = vi.fn();
|
|
52
|
+
render(<TestComponent onSubmit={handleSubmit} />);
|
|
53
|
+
|
|
54
|
+
expect(screen.queryAllByRole('alert')).toHaveLength(0);
|
|
55
|
+
|
|
56
|
+
await user.click(screen.getByText(/submit/i));
|
|
57
|
+
|
|
58
|
+
expect(screen.getByText(/username field is required/i)).toBeInTheDocument();
|
|
59
|
+
expect(screen.getByText(/password field is required/i)).toBeInTheDocument();
|
|
60
|
+
expect(handleSubmit).not.toHaveBeenCalled();
|
|
61
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Field, InternalFieldName } from 'react-hook-form';
|
|
2
|
+
import {
|
|
3
|
+
object,
|
|
4
|
+
string,
|
|
5
|
+
minLength,
|
|
6
|
+
maxLength,
|
|
7
|
+
regex,
|
|
8
|
+
number,
|
|
9
|
+
minValue,
|
|
10
|
+
maxValue,
|
|
11
|
+
email,
|
|
12
|
+
array,
|
|
13
|
+
boolean,
|
|
14
|
+
required,
|
|
15
|
+
union
|
|
16
|
+
} from 'valibot';
|
|
17
|
+
|
|
18
|
+
export const schema = required(
|
|
19
|
+
object({
|
|
20
|
+
username: string([minLength(2), maxLength(30), regex(/^\w+$/)]),
|
|
21
|
+
password: string('New Password is required', [
|
|
22
|
+
regex(new RegExp('.*[A-Z].*'), 'One uppercase character'),
|
|
23
|
+
regex(new RegExp('.*[a-z].*'), 'One lowercase character'),
|
|
24
|
+
regex(new RegExp('.*\\d.*'), 'One number'),
|
|
25
|
+
regex(
|
|
26
|
+
new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'),
|
|
27
|
+
'One special character',
|
|
28
|
+
),
|
|
29
|
+
minLength(8, 'Must be at least 8 characters in length'),
|
|
30
|
+
]),
|
|
31
|
+
repeatPassword: string('Repeat Password is required'),
|
|
32
|
+
accessToken: union([string('Access token should be a string'), number('Access token should be a number')], "access token is required"),
|
|
33
|
+
birthYear: number('Please enter your birth year', [
|
|
34
|
+
minValue(1900),
|
|
35
|
+
maxValue(2013),
|
|
36
|
+
]),
|
|
37
|
+
email: string([email('Invalid email address')]),
|
|
38
|
+
tags: array(string('Tags should be strings')),
|
|
39
|
+
enabled: boolean(),
|
|
40
|
+
like: required(
|
|
41
|
+
object({
|
|
42
|
+
id: number('Like id is required'),
|
|
43
|
+
name: string('Like name is required', [minLength(4, 'Too short')]),
|
|
44
|
+
}),
|
|
45
|
+
),
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export const validData = {
|
|
50
|
+
username: 'Doe',
|
|
51
|
+
password: 'Password123_',
|
|
52
|
+
repeatPassword: 'Password123_',
|
|
53
|
+
birthYear: 2000,
|
|
54
|
+
email: 'john@doe.com',
|
|
55
|
+
tags: ['tag1', 'tag2'],
|
|
56
|
+
enabled: true,
|
|
57
|
+
accessToken: 'accessToken',
|
|
58
|
+
like: {
|
|
59
|
+
id: 1,
|
|
60
|
+
name: 'name',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const invalidData = {
|
|
65
|
+
password: '___',
|
|
66
|
+
email: '',
|
|
67
|
+
birthYear: 'birthYear',
|
|
68
|
+
like: { id: 'z' },
|
|
69
|
+
tags: [1, 2, 3],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const fields: Record<InternalFieldName, Field['_f']> = {
|
|
73
|
+
username: {
|
|
74
|
+
ref: { name: 'username' },
|
|
75
|
+
name: 'username',
|
|
76
|
+
},
|
|
77
|
+
password: {
|
|
78
|
+
ref: { name: 'password' },
|
|
79
|
+
name: 'password',
|
|
80
|
+
},
|
|
81
|
+
email: {
|
|
82
|
+
ref: { name: 'email' },
|
|
83
|
+
name: 'email',
|
|
84
|
+
},
|
|
85
|
+
birthday: {
|
|
86
|
+
ref: { name: 'birthday' },
|
|
87
|
+
name: 'birthday',
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`valibotResolver > should return a single error from valibotResolver when validation fails 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"errors": {
|
|
6
|
+
"accessToken": {
|
|
7
|
+
"message": "Invalid type",
|
|
8
|
+
"ref": undefined,
|
|
9
|
+
"type": "non_optional",
|
|
10
|
+
},
|
|
11
|
+
"birthYear": {
|
|
12
|
+
"message": "Please enter your birth year",
|
|
13
|
+
"ref": undefined,
|
|
14
|
+
"type": "number",
|
|
15
|
+
},
|
|
16
|
+
"email": {
|
|
17
|
+
"message": "Invalid email address",
|
|
18
|
+
"ref": {
|
|
19
|
+
"name": "email",
|
|
20
|
+
},
|
|
21
|
+
"type": "email",
|
|
22
|
+
},
|
|
23
|
+
"enabled": {
|
|
24
|
+
"message": "Invalid type",
|
|
25
|
+
"ref": undefined,
|
|
26
|
+
"type": "non_optional",
|
|
27
|
+
},
|
|
28
|
+
"like": {
|
|
29
|
+
"id": {
|
|
30
|
+
"message": "Like id is required",
|
|
31
|
+
"ref": undefined,
|
|
32
|
+
"type": "number",
|
|
33
|
+
},
|
|
34
|
+
"name": {
|
|
35
|
+
"message": "Invalid type",
|
|
36
|
+
"ref": undefined,
|
|
37
|
+
"type": "non_optional",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
"password": {
|
|
41
|
+
"message": "One uppercase character",
|
|
42
|
+
"ref": {
|
|
43
|
+
"name": "password",
|
|
44
|
+
},
|
|
45
|
+
"type": "regex",
|
|
46
|
+
},
|
|
47
|
+
"repeatPassword": {
|
|
48
|
+
"message": "Invalid type",
|
|
49
|
+
"ref": undefined,
|
|
50
|
+
"type": "non_optional",
|
|
51
|
+
},
|
|
52
|
+
"tags": [
|
|
53
|
+
{
|
|
54
|
+
"message": "Tags should be strings",
|
|
55
|
+
"ref": undefined,
|
|
56
|
+
"type": "string",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"message": "Tags should be strings",
|
|
60
|
+
"ref": undefined,
|
|
61
|
+
"type": "string",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"message": "Tags should be strings",
|
|
65
|
+
"ref": undefined,
|
|
66
|
+
"type": "string",
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
"username": {
|
|
70
|
+
"message": "Invalid type",
|
|
71
|
+
"ref": {
|
|
72
|
+
"name": "username",
|
|
73
|
+
},
|
|
74
|
+
"type": "non_optional",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
"values": {},
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
exports[`valibotResolver > should return a single error from valibotResolver with \`mode: sync\` when validation fails 1`] = `
|
|
82
|
+
{
|
|
83
|
+
"errors": {
|
|
84
|
+
"accessToken": {
|
|
85
|
+
"message": "Invalid type",
|
|
86
|
+
"ref": undefined,
|
|
87
|
+
"type": "non_optional",
|
|
88
|
+
},
|
|
89
|
+
"birthYear": {
|
|
90
|
+
"message": "Please enter your birth year",
|
|
91
|
+
"ref": undefined,
|
|
92
|
+
"type": "number",
|
|
93
|
+
},
|
|
94
|
+
"email": {
|
|
95
|
+
"message": "Invalid email address",
|
|
96
|
+
"ref": {
|
|
97
|
+
"name": "email",
|
|
98
|
+
},
|
|
99
|
+
"type": "email",
|
|
100
|
+
},
|
|
101
|
+
"enabled": {
|
|
102
|
+
"message": "Invalid type",
|
|
103
|
+
"ref": undefined,
|
|
104
|
+
"type": "non_optional",
|
|
105
|
+
},
|
|
106
|
+
"like": {
|
|
107
|
+
"id": {
|
|
108
|
+
"message": "Like id is required",
|
|
109
|
+
"ref": undefined,
|
|
110
|
+
"type": "number",
|
|
111
|
+
},
|
|
112
|
+
"name": {
|
|
113
|
+
"message": "Invalid type",
|
|
114
|
+
"ref": undefined,
|
|
115
|
+
"type": "non_optional",
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
"password": {
|
|
119
|
+
"message": "One uppercase character",
|
|
120
|
+
"ref": {
|
|
121
|
+
"name": "password",
|
|
122
|
+
},
|
|
123
|
+
"type": "regex",
|
|
124
|
+
},
|
|
125
|
+
"repeatPassword": {
|
|
126
|
+
"message": "Invalid type",
|
|
127
|
+
"ref": undefined,
|
|
128
|
+
"type": "non_optional",
|
|
129
|
+
},
|
|
130
|
+
"tags": [
|
|
131
|
+
{
|
|
132
|
+
"message": "Tags should be strings",
|
|
133
|
+
"ref": undefined,
|
|
134
|
+
"type": "string",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"message": "Tags should be strings",
|
|
138
|
+
"ref": undefined,
|
|
139
|
+
"type": "string",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"message": "Tags should be strings",
|
|
143
|
+
"ref": undefined,
|
|
144
|
+
"type": "string",
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
"username": {
|
|
148
|
+
"message": "Invalid type",
|
|
149
|
+
"ref": {
|
|
150
|
+
"name": "username",
|
|
151
|
+
},
|
|
152
|
+
"type": "non_optional",
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
"values": {},
|
|
156
|
+
}
|
|
157
|
+
`;
|
|
158
|
+
|
|
159
|
+
exports[`valibotResolver > should return all the errors from valibotResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = `
|
|
160
|
+
{
|
|
161
|
+
"errors": {
|
|
162
|
+
"accessToken": {
|
|
163
|
+
"message": "Invalid type",
|
|
164
|
+
"ref": undefined,
|
|
165
|
+
"type": "non_optional",
|
|
166
|
+
"types": {
|
|
167
|
+
"non_optional": "Invalid type",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
"birthYear": {
|
|
171
|
+
"message": "Please enter your birth year",
|
|
172
|
+
"ref": undefined,
|
|
173
|
+
"type": "number",
|
|
174
|
+
"types": {
|
|
175
|
+
"number": "Please enter your birth year",
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
"email": {
|
|
179
|
+
"message": "Invalid email address",
|
|
180
|
+
"ref": {
|
|
181
|
+
"name": "email",
|
|
182
|
+
},
|
|
183
|
+
"type": "email",
|
|
184
|
+
"types": {
|
|
185
|
+
"email": "Invalid email address",
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
"enabled": {
|
|
189
|
+
"message": "Invalid type",
|
|
190
|
+
"ref": undefined,
|
|
191
|
+
"type": "non_optional",
|
|
192
|
+
"types": {
|
|
193
|
+
"non_optional": "Invalid type",
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
"like": {
|
|
197
|
+
"id": {
|
|
198
|
+
"message": "Like id is required",
|
|
199
|
+
"ref": undefined,
|
|
200
|
+
"type": "number",
|
|
201
|
+
"types": {
|
|
202
|
+
"number": "Like id is required",
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
"name": {
|
|
206
|
+
"message": "Invalid type",
|
|
207
|
+
"ref": undefined,
|
|
208
|
+
"type": "non_optional",
|
|
209
|
+
"types": {
|
|
210
|
+
"non_optional": "Invalid type",
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
"password": {
|
|
215
|
+
"message": "One uppercase character",
|
|
216
|
+
"ref": {
|
|
217
|
+
"name": "password",
|
|
218
|
+
},
|
|
219
|
+
"type": "regex",
|
|
220
|
+
"types": {
|
|
221
|
+
"min_length": "Must be at least 8 characters in length",
|
|
222
|
+
"regex": [
|
|
223
|
+
"One uppercase character",
|
|
224
|
+
"One lowercase character",
|
|
225
|
+
"One number",
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
"repeatPassword": {
|
|
230
|
+
"message": "Invalid type",
|
|
231
|
+
"ref": undefined,
|
|
232
|
+
"type": "non_optional",
|
|
233
|
+
"types": {
|
|
234
|
+
"non_optional": "Invalid type",
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
"tags": [
|
|
238
|
+
{
|
|
239
|
+
"message": "Tags should be strings",
|
|
240
|
+
"ref": undefined,
|
|
241
|
+
"type": "string",
|
|
242
|
+
"types": {
|
|
243
|
+
"string": "Tags should be strings",
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"message": "Tags should be strings",
|
|
248
|
+
"ref": undefined,
|
|
249
|
+
"type": "string",
|
|
250
|
+
"types": {
|
|
251
|
+
"string": "Tags should be strings",
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"message": "Tags should be strings",
|
|
256
|
+
"ref": undefined,
|
|
257
|
+
"type": "string",
|
|
258
|
+
"types": {
|
|
259
|
+
"string": "Tags should be strings",
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
"username": {
|
|
264
|
+
"message": "Invalid type",
|
|
265
|
+
"ref": {
|
|
266
|
+
"name": "username",
|
|
267
|
+
},
|
|
268
|
+
"type": "non_optional",
|
|
269
|
+
"types": {
|
|
270
|
+
"non_optional": "Invalid type",
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
"values": {},
|
|
275
|
+
}
|
|
276
|
+
`;
|
|
277
|
+
|
|
278
|
+
exports[`valibotResolver > should return all the errors from valibotResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = `
|
|
279
|
+
{
|
|
280
|
+
"errors": {
|
|
281
|
+
"accessToken": {
|
|
282
|
+
"message": "Invalid type",
|
|
283
|
+
"ref": undefined,
|
|
284
|
+
"type": "non_optional",
|
|
285
|
+
"types": {
|
|
286
|
+
"non_optional": "Invalid type",
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
"birthYear": {
|
|
290
|
+
"message": "Please enter your birth year",
|
|
291
|
+
"ref": undefined,
|
|
292
|
+
"type": "number",
|
|
293
|
+
"types": {
|
|
294
|
+
"number": "Please enter your birth year",
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
"email": {
|
|
298
|
+
"message": "Invalid email address",
|
|
299
|
+
"ref": {
|
|
300
|
+
"name": "email",
|
|
301
|
+
},
|
|
302
|
+
"type": "email",
|
|
303
|
+
"types": {
|
|
304
|
+
"email": "Invalid email address",
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
"enabled": {
|
|
308
|
+
"message": "Invalid type",
|
|
309
|
+
"ref": undefined,
|
|
310
|
+
"type": "non_optional",
|
|
311
|
+
"types": {
|
|
312
|
+
"non_optional": "Invalid type",
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
"like": {
|
|
316
|
+
"id": {
|
|
317
|
+
"message": "Like id is required",
|
|
318
|
+
"ref": undefined,
|
|
319
|
+
"type": "number",
|
|
320
|
+
"types": {
|
|
321
|
+
"number": "Like id is required",
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
"name": {
|
|
325
|
+
"message": "Invalid type",
|
|
326
|
+
"ref": undefined,
|
|
327
|
+
"type": "non_optional",
|
|
328
|
+
"types": {
|
|
329
|
+
"non_optional": "Invalid type",
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
"password": {
|
|
334
|
+
"message": "One uppercase character",
|
|
335
|
+
"ref": {
|
|
336
|
+
"name": "password",
|
|
337
|
+
},
|
|
338
|
+
"type": "regex",
|
|
339
|
+
"types": {
|
|
340
|
+
"min_length": "Must be at least 8 characters in length",
|
|
341
|
+
"regex": [
|
|
342
|
+
"One uppercase character",
|
|
343
|
+
"One lowercase character",
|
|
344
|
+
"One number",
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
"repeatPassword": {
|
|
349
|
+
"message": "Invalid type",
|
|
350
|
+
"ref": undefined,
|
|
351
|
+
"type": "non_optional",
|
|
352
|
+
"types": {
|
|
353
|
+
"non_optional": "Invalid type",
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
"tags": [
|
|
357
|
+
{
|
|
358
|
+
"message": "Tags should be strings",
|
|
359
|
+
"ref": undefined,
|
|
360
|
+
"type": "string",
|
|
361
|
+
"types": {
|
|
362
|
+
"string": "Tags should be strings",
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"message": "Tags should be strings",
|
|
367
|
+
"ref": undefined,
|
|
368
|
+
"type": "string",
|
|
369
|
+
"types": {
|
|
370
|
+
"string": "Tags should be strings",
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"message": "Tags should be strings",
|
|
375
|
+
"ref": undefined,
|
|
376
|
+
"type": "string",
|
|
377
|
+
"types": {
|
|
378
|
+
"string": "Tags should be strings",
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
"username": {
|
|
383
|
+
"message": "Invalid type",
|
|
384
|
+
"ref": {
|
|
385
|
+
"name": "username",
|
|
386
|
+
},
|
|
387
|
+
"type": "non_optional",
|
|
388
|
+
"types": {
|
|
389
|
+
"non_optional": "Invalid type",
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
"values": {},
|
|
394
|
+
}
|
|
395
|
+
`;
|
|
396
|
+
|
|
397
|
+
exports[`valibotResolver > should return parsed values from valibotResolver with \`mode: sync\` when validation pass 1`] = `
|
|
398
|
+
{
|
|
399
|
+
"errors": {},
|
|
400
|
+
"values": {
|
|
401
|
+
"accessToken": "accessToken",
|
|
402
|
+
"birthYear": 2000,
|
|
403
|
+
"email": "john@doe.com",
|
|
404
|
+
"enabled": true,
|
|
405
|
+
"like": {
|
|
406
|
+
"id": 1,
|
|
407
|
+
"name": "name",
|
|
408
|
+
},
|
|
409
|
+
"password": "Password123_",
|
|
410
|
+
"repeatPassword": "Password123_",
|
|
411
|
+
"tags": [
|
|
412
|
+
"tag1",
|
|
413
|
+
"tag2",
|
|
414
|
+
],
|
|
415
|
+
"username": "Doe",
|
|
416
|
+
},
|
|
417
|
+
}
|
|
418
|
+
`;
|