From 74a3845918936f3b81c58d7e7b4bac4576c0659a Mon Sep 17 00:00:00 2001 From: Sylvain DENYSE Date: Sun, 15 Oct 2023 12:04:27 +0200 Subject: [PATCH 1/2] style: fix misspelled constraint word --- docs/validation.md | 4 ++-- examples/react-router/src/signup.tsx | 4 ++-- examples/remix/app/routes/signup.tsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/validation.md b/docs/validation.md index 5ce3cd9f..4e3317fa 100644 --- a/docs/validation.md +++ b/docs/validation.md @@ -114,7 +114,7 @@ function createSchema(options?: { z.string().superRefine((email, ctx) => // Using the `refine` helper from Conform refine(ctx, { - validate: () => constarint.isEmailUnique?.(email), + validate: () => constraint.isEmailUnique?.(email), message: 'Username is already used', }), ), @@ -177,7 +177,7 @@ function createSchema( .pipe( z.string().superRefine((email, ctx) => refine(ctx, { - validate: () => constarint.isEmailUnique?.(email), + validate: () => constraint.isEmailUnique?.(email), // Check only when it is validating the email field or submitting when: intent === 'submit' || intent === 'validate/email', message: 'Username is already used', diff --git a/examples/react-router/src/signup.tsx b/examples/react-router/src/signup.tsx index e15dfc3f..3317f131 100644 --- a/examples/react-router/src/signup.tsx +++ b/examples/react-router/src/signup.tsx @@ -8,7 +8,7 @@ import { z } from 'zod'; // Instead of sharing a schema, prepare a schema creator function createSchema( intent: string, - constarint: { + constraint: { // isUsernameUnique is only defined on the server isUsernameUnique?: (username: string) => Promise; } = {}, @@ -25,7 +25,7 @@ function createSchema( .pipe( z.string().superRefine((username, ctx) => refine(ctx, { - validate: () => constarint.isUsernameUnique?.(username), + validate: () => constraint.isUsernameUnique?.(username), when: intent === 'submit' || intent === 'validate/username', message: 'Username is already used', }), diff --git a/examples/remix/app/routes/signup.tsx b/examples/remix/app/routes/signup.tsx index 0e610e34..97b93260 100644 --- a/examples/remix/app/routes/signup.tsx +++ b/examples/remix/app/routes/signup.tsx @@ -8,7 +8,7 @@ import { z } from 'zod'; // Instead of sharing a schema, prepare a schema creator function createSchema( intent: string, - constarint: { + constraint: { // isUsernameUnique is only defined on the server isUsernameUnique?: (username: string) => Promise; } = {}, @@ -25,7 +25,7 @@ function createSchema( .pipe( z.string().superRefine((username, ctx) => refine(ctx, { - validate: () => constarint.isUsernameUnique?.(username), + validate: () => constraint.isUsernameUnique?.(username), when: intent === 'submit' || intent === 'validate/username', message: 'Username is already used', }), From 438f9c675a085aaf31b43061775462865f993a8f Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Tue, 17 Oct 2023 07:02:35 +0200 Subject: [PATCH 2/2] align naming --- docs/validation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/validation.md b/docs/validation.md index 4e3317fa..c64c018b 100644 --- a/docs/validation.md +++ b/docs/validation.md @@ -102,7 +102,7 @@ Here is an example how you can do async validation with zod: import { refine } from '@conform-to/react'; // Instead of reusing a schema, let's prepare a schema creator -function createSchema(options?: { +function createSchema(constraint?: { isEmailUnique?: (email) => Promise; }) { return z.object({