isType<T> function

IValidator isType<T>({
  1. String? message,
})

Returns a Validator that checks if the given value is the correct type

Implementation

IValidator isType<T>({String? message}) {
  return validator(
    (value) => value is T,
    (value) => Expectation(
      message: message ?? T.toString(),
      value: value,
      code: 'type.mismatch',
      data: {
        'expected': T.toString(),
        'found': value.runtimeType.toString(),
      },
    ),
  );
}