Skip to content

Commit

Permalink
Merge branch 'master' into migrate-valibot-to-v0.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller committed Jun 5, 2024
2 parents 3b2e265 + c53864f commit 32ec896
Show file tree
Hide file tree
Showing 9 changed files with 468 additions and 74 deletions.
2 changes: 1 addition & 1 deletion arktype/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hookform/resolvers/arktype",
"amdName": "hookformResolversArktype",
"version": "1.0.0",
"version": "2.0.0",
"private": true,
"description": "React Hook Form validation resolver: arktype",
"main": "dist/arktype.js",
Expand Down
4 changes: 2 additions & 2 deletions arktype/src/__tests__/Form-native-validation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ test("form's native validation with Zod", async () => {
usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement;
expect(usernameField.validity.valid).toBe(false);
expect(usernameField.validationMessage).toBe(
'username must be more than 1 characters (was 0)',
'username must be more than length 1 (was 0)',
);

// password
passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement;
expect(passwordField.validity.valid).toBe(false);
expect(passwordField.validationMessage).toBe(
'password must be more than 1 characters (was 0)',
'password must be more than length 1 (was 0)',
);

await user.type(screen.getByPlaceholderText(/username/i), 'joe');
Expand Down
4 changes: 2 additions & 2 deletions arktype/src/__tests__/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ test("form's validation with arkType and TypeScript's integration", async () =>
await user.click(screen.getByText(/submit/i));

expect(
screen.getByText('username must be more than 1 characters (was 0)'),
screen.getByText('username must be more than length 1 (was 0)'),
).toBeInTheDocument();
expect(
screen.getByText('password must be more than 1 characters (was 0)'),
screen.getByText('password must be more than length 1 (was 0)'),
).toBeInTheDocument();
expect(handleSubmit).not.toHaveBeenCalled();
});
18 changes: 8 additions & 10 deletions arktype/src/__tests__/__fixtures__/data.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { Field, InternalFieldName } from 'react-hook-form';
import { type, arrayOf, union } from 'arktype';
import { type } from 'arktype';

export const schema = type({
username: 'string>2',
password: union(['string>8', '&', '/.*[A-Za-z].*/'], ['/.*\\d.*/']),
password: '/.*[A-Za-z].*/>8|/.*\\d.*/',
repeatPassword: 'string>1',
accessToken: union('string', 'number'),
accessToken: 'string|number',
birthYear: '1900<number<2013',
email: 'email',
tags: arrayOf('string'),
tags: 'string[]',
enabled: 'boolean',
url: 'string>1',
'like?': arrayOf(
type({
id: 'number',
name: 'string>3',
}),
),
'like?': type({
id: 'number',
name: 'string>3',
}).array(),
dateStr: 'Date',
});

Expand Down
Loading

0 comments on commit 32ec896

Please sign in to comment.