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.
Type Parameters
Section titled “Type Parameters”TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends VexResourceSlug = VexResourceSlug
TValue
Section titled “TValue”TValue = unknown
TField
Section titled “TField”TField = unknown
Parameters
Section titled “Parameters”FieldValidateProps<TCollectionSlug, TValue, TField>
Returns
Section titled “Returns”Promise<void> | void