Skip to main content
Not every Effect Schema is valid for use in Confect. Remember that an Effect Schema looks like this:
For Schemas used in Confect:
  • Type represents the value that you’ll be operating on in your code. Any TypeScript type is permitted here.
  • Encoded represents the value that is stored in the database or serialized as the argument/output of a Convex function. This must be a valid Convex value.
  • Context is not currently supported. It should always be never.

Function argument fields

Convex functions always receive an object, so Confect function specs declare args as a Schema.Struct field map rather than as an arbitrary schema:
Confect lazily wraps that field map in Schema.Struct. A full schema such as args: () => Schema.String or args: () => Schema.Struct(...) is therefore not accepted. Top-level struct checks and annotations cannot be attached directly to function args; if you need a cross-field check, nest the checked struct under an argument field. For a function with no arguments, omit args; Confect defaults it to an empty field map ({}).

Additional caveats

No-op returns from Convex functions

Unlike the vanilla APIs, Convex functions defined with Confect may not return undefined or void—use null (Schema.Null as the returns validator) instead. Convex coerces undefined/void returns to null anyways—this just makes that more explicit.