colorFieldToInputSchema
colorFieldToInputSchema(
props):ZodType
Defined in: packages/core/src/fields/color/inputSchema.ts:75
Builds a Zod schema for validating a colour field value in the admin form.
Accepts hex, rgb(), hsl() and oklch() notation — plus var(--token)
when the field enables themeColors. Required fields add a .min(1) check so
an empty field reports “required” rather than a notation complaint. Optional
fields accept the empty string, since color() defaults defaultValue to
"" and a cleared picker must round-trip.
Parameters
Section titled “Parameters”Input props.
The resolved colour field definition.
Returns
Section titled “Returns”ZodType
A Zod string schema. Optional fields are wrapped in .optional() by
applyBaseInputSchemaMeta and carry .default(field.defaultValue).
Example
Section titled “Example”// Required — rejects "", "#fff" and "var(--primary)"colorFieldToInputSchema({ field: color({ required: true }) })
// themeColors — additionally accepts "var(--primary)"colorFieldToInputSchema({ field: color({ required: true, themeColors: true }) })