oneOf

Creates a schema that matches only specified values.

const fishSchema = oneOf(['trout', 'catfish'])();
const fishValidator = validate(fishSchema);
// Returns 'trout'
const trout = fishValidator('trout');
// Throws ValidationError
const salmon = fishValidator('salmon');
Last updated on by Michał Miszczyszyn