numberFieldToInputSchema
numberFieldToInputSchema(
props):ZodType
Defined in: packages/core/src/fields/number/inputSchema.ts:30
Builds a Zod schema for validating a number field value in the admin form.
Applies min/max constraints by composing them onto the same schema
chain built for required, rather than reassigning over it — a required
field with min/max configured keeps every check (CORE-1). Required
fields attach { error: "This field is required." } to the base
z.number() call and never receive .default(), matching
applyBaseInputSchemaMeta’s .optional() gate — a number has no “empty”
state distinct from “missing”, so no .min(1) is added (unlike text).
Only non-required fields get a .default(), clamped into the configured
min/max range.
Parameters
Section titled “Parameters”Input props.
The resolved number field definition
Returns
Section titled “Returns”ZodType
A Zod number schema with range constraints and optionality applied
Example
Section titled “Example”const field = number({ required: true, min: 0, max: [100, "Too large."] })numberFieldToInputSchema({ field })// → z.number({ error: "This field is required." }).min(0, "...").max(100, "Too large.")