1 package org.kuali.common.util.validate.hibernate; 2 3 import javax.validation.ConstraintValidator; 4 import javax.validation.ConstraintValidatorContext; 5 6 public class ValidPassengerCountValidator implements ConstraintValidator<ValidPassengerCount, Car> { 7 8 @Override 9 public void initialize(ValidPassengerCount constraintAnnotation) { 10 } 11 12 @Override 13 public boolean isValid(Car car, ConstraintValidatorContext context) { 14 if (car == null) { 15 return true; 16 } 17 18 return car.getPassengers().size() <= car.getSeatCount(); 19 } 20 }