Backport validateAll function to 4.6
authorSeamus Lee <seamuslee001@gmail.com>
Fri, 18 Nov 2016 22:31:17 +0000 (09:31 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 18 Nov 2016 22:31:17 +0000 (09:31 +1100)
CRM/Utils/Type.php

index c1bd663f9c68693dd4e771c24209e7335a376bad..038d49713e6b7b9c07a3a213f5042adf8c1fb5ac 100644 (file)
@@ -299,6 +299,18 @@ class CRM_Utils_Type {
     return NULL;
   }
 
+  /**
+   * Helper function to call validate on arrays
+   *
+   * @see validate
+   */
+  public static function validateAll($data, $type, $abort = TRUE) {
+    foreach ($data as $key => $value) {
+      $data[$key] = CRM_Utils_Type::validate($value, $type, $abort);
+    }
+    return $data;
+  }
+
   /**
    * Verify that a variable is of a given type.
    *