emailFieldToInputSchema
emailFieldToInputSchema(
props):ZodType
Defined in: packages/core/src/fields/email/inputSchema.ts:39
Builds a Zod schema for validating an email field value in the admin form and the server write pipeline.
The email-format check (.email()) is chained onto the same z.string()
call as min/max — not .pipe()d after them — so every configured
check runs and reports together, matching textFieldToInputSchema’s
CORE-1 composition rule. A required field’s emptiness is checked first
(.min(1, requiredError)) so a missing value reports “This field is
required.” rather than the format error.
A non-required field’s empty string bypasses the format check entirely —
z.union([emailSchema, z.literal("")]), the same escape hatch
urlFieldToInputSchema uses — because an untouched admin-form input holds
"", not undefined, so .default() alone (which only fires on
undefined) can never save an empty optional email from failing
.email().
min/max read field.min/field.max directly as [value, error] —
resolveFieldLimit (step 1) already guarantees error is set whenever
the tuple is present, so no further fallback is needed here.
Parameters
Section titled “Parameters”Input props.
The resolved email field definition.
Returns
Section titled “Returns”ZodType
A Zod schema enforcing required/length/email-format constraints and optionality.
Example
Section titled “Example”const field = email({ required: true, min: [5, "Too short."] })emailFieldToInputSchema({ field })// → required, min-length 5, format-checked string