This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/causeway-app-petclinic.git


The following commit(s) were added to refs/heads/v2 by this push:
     new 8e6d1b6  Updates PhoneNumber meta-annotation, adds regex validation
8e6d1b6 is described below

commit 8e6d1b698bd38cc1cad294c9894da9403888ca70
Author: Dan Haywood <[email protected]>
AuthorDate: Sat May 25 15:25:18 2024 +0100

    Updates PhoneNumber meta-annotation, adds regex validation
---
 .../domainapp/modules/petowner/types/PhoneNumber.java     | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git 
a/module-petowner/src/main/java/domainapp/modules/petowner/types/PhoneNumber.java
 
b/module-petowner/src/main/java/domainapp/modules/petowner/types/PhoneNumber.java
index 9e83aec..89e5779 100644
--- 
a/module-petowner/src/main/java/domainapp/modules/petowner/types/PhoneNumber.java
+++ 
b/module-petowner/src/main/java/domainapp/modules/petowner/types/PhoneNumber.java
@@ -14,15 +14,24 @@ import org.apache.causeway.applib.annotation.Property;
 @Property(
         editing = Editing.ENABLED,
         maxLength = PhoneNumber.MAX_LEN,
-        optionality = Optionality.OPTIONAL
+        optionality = Optionality.OPTIONAL,
+        regexPattern = PhoneNumber.REGEX_PATTERN,
+        regexPatternReplacement = PhoneNumber.REGEX_PATTERN_REPLACEMENT
 )
 @Parameter(
         maxLength = PhoneNumber.MAX_LEN,
-        optionality = Optionality.OPTIONAL
+        optionality = Optionality.OPTIONAL,
+        regexPattern = PhoneNumber.REGEX_PATTERN,
+        regexPatternReplacement = PhoneNumber.REGEX_PATTERN_REPLACEMENT
 )
 @Target({ ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 
ElementType.ANNOTATION_TYPE })
 @Retention(RetentionPolicy.RUNTIME)
 public @interface PhoneNumber {
 
     int MAX_LEN = 40;
-}
+    String REGEX_PATTERN = "[+]?[0-9 ]+";
+    String REGEX_PATTERN_REPLACEMENT =
+            "Specify only numbers and spaces, optionally prefixed with '+'.  " 
+
+            "For example, '+353 1 555 1234', or '07123 456789'";
+
+}
\ No newline at end of file

Reply via email to