Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/routes/_app+/_auth+/forgot-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getSelectProps,
useForm,
} from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import {
data as json,
redirect,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/_auth+/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getSelectProps,
useForm,
} from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import {
data as json,
type ActionFunctionArgs,
Expand Down
5 changes: 2 additions & 3 deletions app/routes/_app+/_auth+/onboarding.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import {
data as json,
redirect,
Expand Down Expand Up @@ -36,8 +36,7 @@ const SignupFormSchema = z
username: UsernameSchema,
name: NameSchema,
agreeToTermsOfServiceAndPrivacyPolicy: z.boolean({
required_error:
'You must agree to the terms of service and privacy policy',
error: 'You must agree to the terms of service and privacy policy',
}),
remember: z.boolean().optional(),
redirectTo: z.string().optional(),
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/_auth+/reset-password.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import {
data as json,
redirect,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/_auth+/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getSelectProps,
useForm,
} from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import {
data as json,
redirect,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/_auth+/verify.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Submission } from '@conform-to/react'
import { parseWithZod } from '@conform-to/zod'
import { parseWithZod } from '@conform-to/zod/v4'
import { data as json } from 'react-router'
import { z } from 'zod'
import { handleVerification as handleChangePhoneNumberVerification } from '#app/routes/_app+/settings.profile+/change-number.server.tsx'
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/_auth+/verify.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import {
type ActionFunctionArgs,
Form,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/admin+/source.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
type ActionFunctionArgs,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/recipients+/$recipientId.index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, getTextareaProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import { invariantResponse } from '@epic-web/invariant'
import {
data as json,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/recipients+/$recipientId.new.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, useForm, getTextareaProps } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import { invariantResponse } from '@epic-web/invariant'
import {
type ActionFunctionArgs,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/recipients+/__editor.server.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseWithZod } from '@conform-to/zod'
import { parseWithZod } from '@conform-to/zod/v4'
import { invariant, invariantResponse } from '@epic-web/invariant'
import { data as json, redirect, type ActionFunctionArgs } from 'react-router'
import { requireUserId } from '#app/utils/auth.server.ts'
Expand Down
30 changes: 17 additions & 13 deletions app/routes/_app+/recipients+/__editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getSelectProps,
useForm,
} from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import { useState } from 'react'
import { Form, useActionData, useFetcher } from 'react-router'
import { z } from 'zod'
Expand Down Expand Up @@ -33,18 +33,15 @@ export const RecipientEditorSchema = z.object({
scheduleCron: z
.string()
.min(1, 'Cron string is required')
.refine(
(cronString) => {
const validation = validateCronString(cronString)
return validation.valid
},
(cronString) => {
const validation = validateCronString(cronString)
return {
.superRefine((cronString, ctx) => {
const validation = validateCronString(cronString)
if (!validation.valid) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: validation.error || 'Invalid cron string',
}
},
),
})
}
}),
timeZone: z.string(),
disabled: z.coerce.boolean().optional().default(false),
})
Expand Down Expand Up @@ -86,7 +83,14 @@ export function RecipientEditor({
return parseWithZod(formData, { schema: RecipientEditorSchema })
},
defaultValue: recipient
? { ...recipient, disabled: recipient.disabled ?? false }
? {
id: recipient.id,
name: recipient.name,
phoneNumber: recipient.phoneNumber,
scheduleCron: recipient.scheduleCron,
timeZone: recipient.timeZone,
disabled: recipient.disabled ? 'on' : undefined,
}
: undefined,
shouldRevalidate: 'onBlur',
})
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/settings.profile+/change-number.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
Form,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/settings.profile+/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import { invariantResponse } from '@epic-web/invariant'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_app+/settings.profile+/password.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
Form,
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_app+/settings.profile+/two-factor.verify.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { getZodConstraint, parseWithZod } from '@conform-to/zod/v4'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import * as QRCode from 'qrcode'
import {
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function action({ request }: ActionFunctionArgs) {
const submission = await parseWithZod(formData, {
schema: () =>
ActionSchema.superRefine(async (data, ctx) => {
if (data.intent === 'cancel') return null
if (data.intent === 'cancel') return
const codeIsValid = await isCodeValid({
code: data.code,
type: twoFAVerifyVerificationType,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/resources+/theme-switch.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useForm, getFormProps } from '@conform-to/react'
import { parseWithZod } from '@conform-to/zod'
import { parseWithZod } from '@conform-to/zod/v4'
import { invariantResponse } from '@epic-web/invariant'
import {
data as json,
Expand Down
8 changes: 4 additions & 4 deletions app/utils/user-validation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from 'zod'

export const UsernameSchema = z
.string({ required_error: 'Username is required' })
.string({ error: 'Username is required' })
.min(3, { message: 'Username is too short' })
.max(20, { message: 'Username is too long' })
.regex(/^[a-zA-Z0-9_]+$/, {
Expand All @@ -11,16 +11,16 @@ export const UsernameSchema = z
.transform((value) => value.trim().toLowerCase())

export const PasswordSchema = z
.string({ required_error: 'Password is required' })
.string({ error: 'Password is required' })
.min(6, { message: 'Password is too short' })
.max(100, { message: 'Password is too long' })
export const NameSchema = z
.string({ required_error: 'Name is required' })
.string({ error: 'Name is required' })
.min(3, { message: 'Name is too short' })
.max(40, { message: 'Name is too long' })

export const PhoneNumberSchema = z
.string({ required_error: 'Phone number is required' })
.string({ error: 'Phone number is required' })
.min(3, { message: 'Phone number is too short' })
.max(30, { message: 'Phone number is too long' })
.transform((value) => value.trim())
Expand Down
Loading
Loading