isOneOf<T> function

IValidator isOneOf<T>(
  1. List<T> options
)

Checks whether the given value is one of the options values of type T

Implementation

IValidator isOneOf<T>(List<T> options) => all([
      isType<T>(),
      Validator(
        (value) => Result(
          isValid: options.contains(value),
          expectations: [
            Expectation(message: 'one of: ${prettifyValue(options)}', value: value, code: 'value_not_in_set', data: {'options': options.map((e)=>e.toString()).toList()} )
          ],
          value: value,
        ),
      ),
    ]);