feat: upgrade to zod v4 & fix z.url() and z.email()
https://zod.dev/v4/changelog?id=zstring-updates
This commit is contained in:
parent
8b2f1848a8
commit
89fd7193ac
@ -9,7 +9,7 @@ const actionClient = createSafeActionClient();
|
|||||||
|
|
||||||
// Newsletter schema for validation
|
// Newsletter schema for validation
|
||||||
const newsletterSchema = z.object({
|
const newsletterSchema = z.object({
|
||||||
email: z.string().email({ message: 'Please enter a valid email address' }),
|
email: z.email({ message: 'Please enter a valid email address' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a safe action to check if a user is subscribed to the newsletter
|
// Create a safe action to check if a user is subscribed to the newsletter
|
||||||
|
@ -19,7 +19,7 @@ const contactFormSchema = z.object({
|
|||||||
.string()
|
.string()
|
||||||
.min(3, { message: 'Name must be at least 3 characters' })
|
.min(3, { message: 'Name must be at least 3 characters' })
|
||||||
.max(30, { message: 'Name must not exceed 30 characters' }),
|
.max(30, { message: 'Name must not exceed 30 characters' }),
|
||||||
email: z.string().email({ message: 'Please enter a valid email address' }),
|
email: z.email({ message: 'Please enter a valid email address' }),
|
||||||
message: z
|
message: z
|
||||||
.string()
|
.string()
|
||||||
.min(10, { message: 'Message must be at least 10 characters' })
|
.min(10, { message: 'Message must be at least 10 characters' })
|
||||||
|
@ -11,7 +11,7 @@ const actionClient = createSafeActionClient();
|
|||||||
|
|
||||||
// Newsletter schema for validation
|
// Newsletter schema for validation
|
||||||
const newsletterSchema = z.object({
|
const newsletterSchema = z.object({
|
||||||
email: z.string().email({ message: 'Please enter a valid email address' }),
|
email: z.email({ message: 'Please enter a valid email address' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a safe action for newsletter subscription
|
// Create a safe action for newsletter subscription
|
||||||
|
@ -10,7 +10,7 @@ const actionClient = createSafeActionClient();
|
|||||||
|
|
||||||
// Newsletter schema for validation
|
// Newsletter schema for validation
|
||||||
const newsletterSchema = z.object({
|
const newsletterSchema = z.object({
|
||||||
email: z.string().email({ message: 'Please enter a valid email address' }),
|
email: z.email({ message: 'Please enter a valid email address' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a safe action for newsletter unsubscription
|
// Create a safe action for newsletter unsubscription
|
||||||
|
@ -40,7 +40,7 @@ import { useDebounce } from '../utils/performance';
|
|||||||
|
|
||||||
// Form schema for URL input
|
// Form schema for URL input
|
||||||
const urlFormSchema = z.object({
|
const urlFormSchema = z.object({
|
||||||
url: z.string().url().optional(), // Allow empty string for initial state
|
url: z.url().optional(), // Allow empty string for initial state
|
||||||
});
|
});
|
||||||
|
|
||||||
type UrlFormData = z.infer<typeof urlFormSchema>;
|
type UrlFormData = z.infer<typeof urlFormSchema>;
|
||||||
|
@ -32,7 +32,7 @@ export const ForgotPasswordForm = ({ className }: { className?: string }) => {
|
|||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
const ForgotPasswordSchema = z.object({
|
const ForgotPasswordSchema = z.object({
|
||||||
email: z.string().email({
|
email: z.email({
|
||||||
message: t('emailRequired'),
|
message: t('emailRequired'),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -69,7 +69,7 @@ export const LoginForm = ({
|
|||||||
: z.string().optional();
|
: z.string().optional();
|
||||||
|
|
||||||
const LoginSchema = z.object({
|
const LoginSchema = z.object({
|
||||||
email: z.string().email({
|
email: z.email({
|
||||||
message: t('emailRequired'),
|
message: t('emailRequired'),
|
||||||
}),
|
}),
|
||||||
password: z.string().min(1, {
|
password: z.string().min(1, {
|
||||||
|
@ -64,7 +64,7 @@ export const RegisterForm = ({
|
|||||||
: z.string().optional();
|
: z.string().optional();
|
||||||
|
|
||||||
const RegisterSchema = z.object({
|
const RegisterSchema = z.object({
|
||||||
email: z.string().email({
|
email: z.email({
|
||||||
message: t('emailRequired'),
|
message: t('emailRequired'),
|
||||||
}),
|
}),
|
||||||
password: z.string().min(1, {
|
password: z.string().min(1, {
|
||||||
|
@ -40,7 +40,7 @@ export function ContactFormCard() {
|
|||||||
// Create a schema for contact form validation
|
// Create a schema for contact form validation
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
name: z.string().min(3, t('nameMinLength')).max(30, t('nameMaxLength')),
|
name: z.string().min(3, t('nameMinLength')).max(30, t('nameMaxLength')),
|
||||||
email: z.string().email(t('emailValidation')),
|
email: z.email(t('emailValidation')),
|
||||||
message: z
|
message: z
|
||||||
.string()
|
.string()
|
||||||
.min(10, t('messageMinLength'))
|
.min(10, t('messageMinLength'))
|
||||||
|
@ -29,7 +29,7 @@ export function NewsletterForm() {
|
|||||||
|
|
||||||
// newsletter schema
|
// newsletter schema
|
||||||
const NewsletterFormSchema = z.object({
|
const NewsletterFormSchema = z.object({
|
||||||
email: z.string().email({
|
email: z.email({
|
||||||
message: t('emailValidation'),
|
message: t('emailValidation'),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -38,7 +38,7 @@ export function WaitlistFormCard() {
|
|||||||
|
|
||||||
// Create a schema for waitlist form validation
|
// Create a schema for waitlist form validation
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
email: z.string().email({ message: t('emailValidation') }),
|
email: z.email({ message: t('emailValidation') }),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize the form
|
// Initialize the form
|
||||||
|
Loading…
Reference in New Issue
Block a user