0

Trying to read regex values from yaml file in POJO class. like this,

@Pattern(regexp = "${something.value}")
private String someValue;

But this is not working because its expecting below, (Within annotations you can only refer to constant expressions)

Pattern.regexp must be a constant expression at run time.

Am curious if there is any solution for this case with only supporting Annotations or calling some get/set methods at runtime which holds value of config.

Not really looking for custom validator solution though.

Thanks for your help in advance.

Satscreate
  • 495
  • 12
  • 38
  • Is this the same thing ? https://stackoverflow.com/questions/46591861/dynamic-pojo-validation-based-on-groups-in-spring –  Jul 14 '20 at 14:57
  • @Maxt8r not really with Strategy Pattern .. Looking for annotation with reading capabilities from yaml. – Satscreate Jul 14 '20 at 15:14
  • I don't think it's possible. That @Pattern annotation is evaluated at compile time. While the values from the YAML file is evaluated at run time. – Duc D. Nguyen Jul 14 '20 at 18:43

0 Answers0