fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-lang] 01/08: Added optional option for valididentifier_s_ validation.
Date Mon, 22 Jan 2018 15:53:05 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-lang.git

commit a46bc1f98a9b7fe1c01e74b8f6fae33b9724735c
Author: Myrle Krantz <myrle@apache.org>
AuthorDate: Thu Aug 17 11:06:36 2017 +0200

    Added optional option for valididentifier_s_ validation.
---
 src/main/java/io/mifos/core/lang/validation/CheckIdentifiers.java   | 6 ++++++
 .../io/mifos/core/lang/validation/constraints/ValidIdentifiers.java | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/main/java/io/mifos/core/lang/validation/CheckIdentifiers.java b/src/main/java/io/mifos/core/lang/validation/CheckIdentifiers.java
index 183b6ac..f739eb3 100644
--- a/src/main/java/io/mifos/core/lang/validation/CheckIdentifiers.java
+++ b/src/main/java/io/mifos/core/lang/validation/CheckIdentifiers.java
@@ -26,14 +26,20 @@ import java.util.List;
  */
 public class CheckIdentifiers implements ConstraintValidator<ValidIdentifiers, List<String>>
{
   private int maximumLength = 32;
+  private boolean optional;
+
   @Override
   public void initialize(final ValidIdentifiers constraintAnnotation) {
     maximumLength = constraintAnnotation.maxLength();
+    optional = constraintAnnotation.optional();
 
   }
 
   @Override
   public boolean isValid(final List<String> value, final ConstraintValidatorContext
context) {
+    if (optional && value == null)
+      return true;
+
     return value != null && value.stream().allMatch(x -> x != null &&
CheckIdentifier.validate(x, maximumLength));
   }
 }
diff --git a/src/main/java/io/mifos/core/lang/validation/constraints/ValidIdentifiers.java
b/src/main/java/io/mifos/core/lang/validation/constraints/ValidIdentifiers.java
index d881860..f4b2533 100644
--- a/src/main/java/io/mifos/core/lang/validation/constraints/ValidIdentifiers.java
+++ b/src/main/java/io/mifos/core/lang/validation/constraints/ValidIdentifiers.java
@@ -43,4 +43,5 @@ public @interface ValidIdentifiers {
   Class<? extends Payload>[] payload() default { };
 
   int maxLength() default 32;
+  boolean optional() default false;
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message