Skip to content

Function: asOneOf()

asOneOf<T>(values, options?): TTransformer<T[number], TUnion<TLiteral<T[number]>[]>>

Create an oneOf transformer. Value must be parsable as one of the given values.

Type Parameters

Type Parameter
T extends TLiteralValue[]

Parameters

ParameterTypeDescription
valuesreadonly [T]An array of expected values
options?SchemaOptionsValidation options (see NumberOptions)

Returns

TTransformer<T[number], TUnion<TLiteral<T[number]>[]>>

Example

ts
Column('createdAt', asOneOf(['Todo', 'Doing', 'Done']));

Defined in

src/transformer/as-one-of.ts:21

Released under the MIT License.