You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following two schemas that work together to validate a signup form. Note the use of the two check methods and the continue properties on the passwordSchema:
exportconstpasswordSchema=z.string({error: 'Password is required.'}).min(8,'Password must be at least 8 characters long.').max(32,'Password must be less than 32 characters long.').check((ctx)=>{constcomplexity=getPasswordComplexity(ctx.value);if(complexity.feedback.warning?.toLowerCase().includes('common')){ctx.issues.push({code: 'custom',message: 'This password is too common. Please choose a stronger one.',input: ctx.value,continue: true//<---here});}if(!complexity.meetsRequirements){ctx.issues.push({code: 'custom',message: 'Password is not strong enough.',input: ctx.value,continue: true//<---and here});}});
...
exportconstsignUpSchema=z.object({email: emailSchema,firstName: z.string().min(1,{message: 'First name is required.'}),lastName: z.string().min(1,{message: 'Last name is required.'}),password: passwordSchema,confirmPassword: z.string().min(1,{message: 'Confirm password is required.'}),}).check((ctx)=>{if(ctx.value.password!==ctx.value.confirmPassword){ctx.issues.push({code: 'custom',message: 'Passwords do not match.',input: ctx.value.confirmPassword,path: ['confirmPassword'],});}});
This works fine, but continue is marked as deprecated now:
/** @deprecated Internal use only. If `true`, Zod will continue executing validation despite this issue. */
readonlycontinue?: boolean|undefined;
Without this, the check for the confirmation password just doesn't run at all.
So my question is, as continue is deprecated, how am I supposed to make sure the second check is called? Obviously I can just continue to use continue, but it must have been deprecated for a reason?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
So I am v4 confused.
I have the following two schemas that work together to validate a signup form. Note the use of the two
checkmethods and thecontinueproperties on thepasswordSchema:This works fine, but
continueis marked as deprecated now:zod/packages/zod/src/v4/core/errors.ts
Lines 165 to 166 in 499df78
Without this, the check for the confirmation password just doesn't run at all.
So my question is, as
continueis deprecated, how am I supposed to make sure the secondcheckis called? Obviously I can just continue to usecontinue, but it must have been deprecated for a reason?Skill issue for sure.. 😄
Beta Was this translation helpful? Give feedback.
All reactions