You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2021/10/02 15:57:35 UTC
[isis-app-demo] branch main updated (6249707 -> f976755)
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/isis-app-demo.git.
from 6249707 adds phoneNumber and emailAddress to PetOwner
new 71c5e43 updates PhoneNumber with regex pattern.
new e1c3eed updates EmailAddress with regex pattern.
new f976755 moves validation logic for lastName from property to meta-annotation
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../petclinic/modules/pets/dom/petowner/PetOwner.java | 8 --------
.../java/petclinic/modules/pets/types/EmailAddress.java | 4 +++-
.../main/java/petclinic/modules/pets/types/LastName.java | 16 ++++++++++++++--
.../java/petclinic/modules/pets/types/PhoneNumber.java | 6 +++++-
4 files changed, 22 insertions(+), 12 deletions(-)
[isis-app-demo] 03/03: moves validation logic for lastName from
property to meta-annotation
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/isis-app-demo.git
commit f9767553e32a9dfb745f8f6ca44439eea260797d
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Sat Oct 2 16:56:00 2021 +0100
moves validation logic for lastName from property to meta-annotation
---
.../petclinic/modules/pets/dom/petowner/PetOwner.java | 8 --------
.../main/java/petclinic/modules/pets/types/LastName.java | 16 ++++++++++++++--
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/module-pets/src/main/java/petclinic/modules/pets/dom/petowner/PetOwner.java b/module-pets/src/main/java/petclinic/modules/pets/dom/petowner/PetOwner.java
index 6ccb3a9..e794a58 100644
--- a/module-pets/src/main/java/petclinic/modules/pets/dom/petowner/PetOwner.java
+++ b/module-pets/src/main/java/petclinic/modules/pets/dom/petowner/PetOwner.java
@@ -157,14 +157,6 @@ public class PetOwner implements Comparable<PetOwner> {
public String default1UpdateName() {
return getFirstName();
}
- public String validate0UpdateName(String newName) {
- for (char prohibitedCharacter : "&%$!".toCharArray()) {
- if( newName.contains(""+prohibitedCharacter)) {
- return "Character '" + prohibitedCharacter + "' is not allowed.";
- }
- }
- return null;
- }
@Action(semantics = NON_IDEMPOTENT_ARE_YOU_SURE)
diff --git a/module-pets/src/main/java/petclinic/modules/pets/types/LastName.java b/module-pets/src/main/java/petclinic/modules/pets/types/LastName.java
index 0c85796..5fe25bc 100644
--- a/module-pets/src/main/java/petclinic/modules/pets/types/LastName.java
+++ b/module-pets/src/main/java/petclinic/modules/pets/types/LastName.java
@@ -8,13 +8,25 @@ import java.lang.annotation.Target;
import org.apache.isis.applib.annotation.Parameter;
import org.apache.isis.applib.annotation.ParameterLayout;
import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.applib.spec.AbstractSpecification;
-@Property(maxLength = LastName.MAX_LEN)
-@Parameter(maxLength = LastName.MAX_LEN)
+@Property(maxLength = LastName.MAX_LEN, mustSatisfy = LastName.Spec.class)
+@Parameter(maxLength = LastName.MAX_LEN, mustSatisfy = LastName.Spec.class)
@ParameterLayout(named = "Last Name")
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface LastName {
int MAX_LEN = 40;
+
+ class Spec extends AbstractSpecification<String> {
+ @Override public String satisfiesSafely(String candidate) {
+ for (char prohibitedCharacter : "&%$!".toCharArray()) {
+ if( candidate.contains(""+prohibitedCharacter)) {
+ return "Character '" + prohibitedCharacter + "' is not allowed.";
+ }
+ }
+ return null;
+ }
+ }
}
[isis-app-demo] 01/03: updates PhoneNumber with regex pattern.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/isis-app-demo.git
commit 71c5e4329840c47d68a201c3ec5fd3f2bf78b665
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Sat Oct 2 16:55:14 2021 +0100
updates PhoneNumber with regex pattern.
---
.../src/main/java/petclinic/modules/pets/types/PhoneNumber.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/module-pets/src/main/java/petclinic/modules/pets/types/PhoneNumber.java b/module-pets/src/main/java/petclinic/modules/pets/types/PhoneNumber.java
index 711fe6f..33821cf 100644
--- a/module-pets/src/main/java/petclinic/modules/pets/types/PhoneNumber.java
+++ b/module-pets/src/main/java/petclinic/modules/pets/types/PhoneNumber.java
@@ -15,7 +15,11 @@ import org.apache.isis.applib.annotation.PropertyLayout;
@Property(
editing = Editing.ENABLED,
maxLength = PhoneNumber.MAX_LEN,
- optionality = Optionality.OPTIONAL
+ optionality = Optionality.OPTIONAL,
+ regexPattern = "[+]?[0-9 ]+",
+ regexPatternReplacement =
+ "Specify only numbers and spaces, optionally prefixed with '+'. " +
+ "For example, '+353 1 555 1234', or '07123 456789'"
)
@Parameter(maxLength = PhoneNumber.MAX_LEN, optionality = Optionality.OPTIONAL)
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
[isis-app-demo] 02/03: updates EmailAddress with regex pattern.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/isis-app-demo.git
commit e1c3eed459db670d892b523d7db469de8f18f12e
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Sat Oct 2 16:55:30 2021 +0100
updates EmailAddress with regex pattern.
---
.../src/main/java/petclinic/modules/pets/types/EmailAddress.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/module-pets/src/main/java/petclinic/modules/pets/types/EmailAddress.java b/module-pets/src/main/java/petclinic/modules/pets/types/EmailAddress.java
index ad2833e..fc69256 100644
--- a/module-pets/src/main/java/petclinic/modules/pets/types/EmailAddress.java
+++ b/module-pets/src/main/java/petclinic/modules/pets/types/EmailAddress.java
@@ -15,7 +15,9 @@ import org.apache.isis.applib.annotation.PropertyLayout;
@Property(
editing = Editing.ENABLED,
maxLength = EmailAddress.MAX_LEN,
- optionality = Optionality.OPTIONAL
+ optionality = Optionality.OPTIONAL,
+ regexPattern = "[^@]+@[^@]+[.][^@]+", // should really use https://emailregex.com/
+ regexPatternReplacement = "Invalid email address"
)
@PropertyLayout(named = "E-mail")
@Parameter(maxLength = EmailAddress.MAX_LEN, optionality = Optionality.OPTIONAL)