supports method

  1. @override
bool supports(
  1. Object value
)
override

Whether the constraint can check a value of this type at all; value is never null. @Size supports strings, collections and maps, not an int.

When it returns false, BeanValidator throws an UnexpectedTypeException instead of calling isValid: the declaration is wrong, not the value (Hibernate Validator finds no ConstraintValidator for the type). Returns true by default; override it in a custom constraint that only makes sense for some types.

Implementation

@override
bool supports(Object value) => value is bool;