isEq<T> function

IValidator isEq<T>(
  1. T otherValue, {
  2. String? message,
})

Checks whether the given value is equal to the otherValue value of type T

Even though this function accepts any Type, note that it will not work with Collections. For that usecase prefer using isDeepEq instead.

Implementation

IValidator isEq<T>(T otherValue, {String? message}) =>
    validator(
      (value) => value == otherValue,
      (value) => Expectation(
        message: message ?? 'equal to ${prettifyValue(otherValue)}',
        value: value,
        code: ExpectationCodes.valueEqualMismatch,
        data: {
          'expected': prettifyValue(otherValue),
          'found': prettifyValue(value),
          'mode': 'shallow'
        },
      ),
    );