Skip to content

FieldValidate

FieldValidate<TCollectionSlug, TValue, TField> = (props) => Promise<void> | void

Defined in: packages/core/src/fields/baseTypes.ts:126

Custom server-side validation for one field, run after the generated Zod schema passes. Async and ctx-bearing, so a uniqueness check (ctx.db.query(...).withIndex(...)) is sound inside a Convex mutation’s transaction. Never runs on the client.

Reject by throwing. Throw anything — a plain Error, a project-specific subclass, or a ConvexError with structured data (codes, hints, the conflicting document’s id). validateFields catches it, attaches the field key, and re-throws one ConvexError shape. Returning normally means the value is accepted.

TCollectionSlug extends VexResourceSlug = VexResourceSlug

TValue = unknown

TField = unknown

FieldValidateProps<TCollectionSlug, TValue, TField>

Promise<void> | void