Update MaxSizeConstraintValidator.java

This commit is contained in:
Pallavi Priyadarshani 2019-08-12 03:55:13 +05:30 committed by GitHub
parent b3af5e65b7
commit 28e18be37a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 7 deletions

View File

@ -12,15 +12,10 @@ public class MaxSizeConstraintValidator implements ConstraintValidator<MaxSizeCo
@Override
public boolean isValid(List<Movie> 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;
}
}