Suppose, I have a model like below - public class A{ public List<String> phoneNumbers; } I want to apply @Max validation, so as to not allow phoneNumbers more then a certain limit. And, it is required to have this limit configurable in properties file. By Default, @Max takes static values. We can not pass value read from application.properties to this annotation. So, we can write custom annotation like below - import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import javax.validation.Constraint; import javax.validation.Payload; @Target({ ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME) @Documented @Constraint(validatedBy = FieldValidator.class) public @interface MaxAllowedSize { String message() default "size of list must be less than or equal to %s"; Class<?>[] groups() default {}; Class<? exte