0

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
Rpj
  • 5,348
  • 16
  • 62
  • 122

1 Answers1

0

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

Christian Beikov
  • 15,141
  • 2
  • 32
  • 58