Skip to content

bytesFieldToInputSchema

bytesFieldToInputSchema(props): ZodType

Defined in: packages/core/src/fields/bytes/inputSchema.ts:26

Builds a Zod schema for validating a bytes field value in the admin form.

z.instanceof(ArrayBuffer) plus a size .refine() against field.maxSize — the same limit the admin form’s File/Hex control enforces client-side. A required field rejects undefined with “This field is required.”; a non-required field accepts a missing value.

Input props.

BytesField

The resolved bytes field definition

ZodType

A Zod schema accepting an ArrayBuffer no larger than field.maxSize

const field = bytes({ required: true, maxSize: 4 })
bytesFieldToInputSchema({ field })
// → z.instanceof(ArrayBuffer).refine(...) — rejects undefined and >4-byte buffers