a typed StringSchemaBuilder that only accepts the given values
Creates a string schema constrained to the given literal values.
Convenience factory equivalent to string().oneOf(...values).
Mirrors Zod's z.enum(['admin', 'user', 'guest']) API.
Rest-params form (no custom error message):
const Role = enumOf('admin', 'user', 'guest');
Array form (with optional custom error message):
const Role = enumOf(['admin', 'user', 'guest'], 'Invalid role');
const Role2 = enumOf(['admin', 'user'], (val) => `"${val}" is not a valid role`);
the allowed string literals (at least one required)
OptionalerrorMessage: ValidationErrorMessageProvider<a typed StringSchemaBuilder that only accepts the given values
Creates a string schema constrained to the given literal values.
Convenience factory equivalent to
string().oneOf(...values). Mirrors Zod'sz.enum(['admin', 'user', 'guest'])API.Rest-params form (no custom error message):
Array form (with optional custom error message):