diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java b/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java index 813ea3e657..0154fb636a 100644 --- a/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java @@ -12,15 +12,10 @@ public class MaxSizeConstraintValidator implements ConstraintValidator values, ConstraintValidatorContext context) { boolean isValid = true; - if (values == null || values.isEmpty()) { - isValid = false; - context.disableDefaultConstraintViolation(); - context.buildConstraintViolationWithTemplate("Movie list cannot be empty.") - .addConstraintViolation(); - } else if (values.size() > 4) { + if (values.size() > 4) { isValid = false; } return isValid; } - + }