habuma / spring-in-action-6-samples

Sample code from Spring in Action 6
486 stars 342 forks source link

CVV validation incorrect #21

Open KianYang-Lee opened 1 year ago

KianYang-Lee commented 1 year ago

For the domain TacoOrder, as CVV needs to be 3 digits, the current validation presented does not check for the minimum digits required, rather only the maximum digits allowed.

Suggest to use the following regex pattern matching for constraint:

@Pattern(regexp = "^[0-9]{3}$", message = "Must be 3 digits")
private String ccCVV;