@conform-to/zod
Advanced tools
Comparing version 0.7.3 to 0.7.4
@@ -13,2 +13,3 @@ import { type FieldsetConstraint, type Submission } from '@conform-to/dom'; | ||
errorMap?: z.ZodErrorMap; | ||
stripEmptyValue?: boolean; | ||
}): Submission<z.output<Schema>>; | ||
@@ -24,2 +25,3 @@ export declare function parse<Schema extends z.ZodTypeAny>(payload: FormData | URLSearchParams, config: { | ||
errorMap?: z.ZodErrorMap; | ||
stripEmptyValue?: boolean; | ||
}): Promise<Submission<z.output<Schema>>>; | ||
@@ -26,0 +28,0 @@ /** |
@@ -34,2 +34,4 @@ 'use strict'; | ||
constraint = _rollupPluginBabelHelpers.objectSpread2({}, inferConstraint(schema.innerType())); | ||
} else if (schema instanceof z__namespace.ZodPipeline) { | ||
constraint = _rollupPluginBabelHelpers.objectSpread2({}, inferConstraint(schema._def.out)); | ||
} else if (schema instanceof z__namespace.ZodOptional) { | ||
@@ -140,2 +142,3 @@ constraint = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, inferConstraint(schema.unwrap())), {}, { | ||
return dom.parse(payload, { | ||
stripEmptyValue: config.stripEmptyValue, | ||
resolve(payload, intent) { | ||
@@ -142,0 +145,0 @@ var schema = typeof config.schema === 'function' ? config.schema(intent) : config.schema; |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"main": "index.js", | ||
@@ -29,3 +29,3 @@ "module": "index.mjs", | ||
"peerDependencies": { | ||
"@conform-to/dom": "0.7.3", | ||
"@conform-to/dom": "0.7.4", | ||
"zod": "^3.21.0" | ||
@@ -32,0 +32,0 @@ }, |
@@ -27,4 +27,4 @@ # @conform-to/zod | ||
const schema = z.object({ | ||
email: z.string().min(1, 'Email is required'), | ||
password: z.string().min(1, 'Password is required'), | ||
email: z.string({ required_error: 'Email is required' }), | ||
password: z.string({ required_error: 'Password is required' }), | ||
}); | ||
@@ -51,4 +51,4 @@ | ||
const schema = z.object({ | ||
email: z.string().min(1, 'Email is required'), | ||
password: z.string().min(1, 'Password is required'), | ||
email: z.string({ required_error: 'Email is required' }), | ||
password: z.string({ required_error: 'Password is required' }), | ||
}); | ||
@@ -59,3 +59,6 @@ | ||
onValidate({ formData }) { | ||
return parse(formData, { schema }); | ||
return parse(formData, { | ||
schema, | ||
stripEmptyValue: true, | ||
}); | ||
}, | ||
@@ -85,2 +88,5 @@ }); | ||
// Recommended: this will be the default in the future | ||
stripEmptyValue: true, | ||
// If the schema definition includes async validation | ||
@@ -114,4 +120,3 @@ async: true, | ||
email: z | ||
.string() | ||
.min(1, 'Email is required') | ||
.string({ required_error: 'Email is required' }) | ||
.email('Email is invalid') | ||
@@ -118,0 +123,0 @@ .superRefine((email, ctx) => |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26178
578
132