How to validate AWS ARN using JPA validator with Hibernate as the provider. Should we use a regex pattern
For example, we would like to make sure that it starts with arn:aws:iam
for the following role
arn:aws:iam::344492858010:role/ABC_role
arn:aws:iam::355433858011:role/DEF_role
CodePudding user response:
Use the @Pattern
annotation and write a regex that matches only valid ARNs. Also see https://docs.jboss.org/hibernate/beanvalidation/spec/2.0/api/javax/validation/constraints/Pattern.html