Fixes for oparent upgrade
[policy/engine.git] / PolicyEngineUtils / src / main / java / org / onap / policy / utils / PolicyUtils.java
index e17ddc6..67210c8 100644 (file)
@@ -157,6 +157,21 @@ public class PolicyUtils {
         return SUCCESS;   
     } 
     
+    /**
+     * Validate a field (accepts Dash) if it contains unacceptable policy input and return "success" if good. 
+     * 
+     * @param field
+     * @return
+     */
+    public static String  policySpecialCharWithDashValidator(String field){
+        String error;
+        if ("".equals(field) || !field.matches("^[a-zA-Z0-9_-]*$")) {
+            error = "The Value in Required Field will allow only '{0-9}, {a-z}, {A-Z}, _, -' following set of Combinations";
+            return error;
+        }
+        return SUCCESS;   
+    } 
+    
     /**
      * Validate the XACML description tag and return "success" if good. 
      * 
@@ -181,7 +196,7 @@ public class PolicyUtils {
      * @return
      */
     public static boolean containsNonAsciiEmptyChars(String value) {
-        return (value == null|| value.contains(" ") || "".equals(value.trim())|| !CharMatcher.ASCII.matchesAllOf((CharSequence) value))? true:false;
+        return (value == null || value.contains(" ") || "".equals(value.trim()) || !CharMatcher.ascii().matchesAllOf((CharSequence) value)) ? true : false;
     }
     
     /**