===) to one of the specified values.
Signature
Type Inference
oneOf() creates a union type of literal types:
Basic Usage
Scalar Values Only
oneOf() only works with scalar values (string, number, boolean, null, undefined, symbol):
String Literal Unions
oneOf() is perfect for string literal union types:
Error Messages
Numeric Literals
Boolean Unions
vs constant()
For a single value, useconstant(). For multiple values, use oneOf():
vs either()
oneOf() is optimized for scalar values and uses === equality. either() is for combining different decoders:
TypeScript Enums
For TypeScript enums, use theenum_() decoder instead:
