You are here

function isValid in Bynder 7

4 calls to isValid()
validateBynderDrupalUrl in includes/bynder.utils.inc
validateId in includes/bynder.utils.inc
validateIdHash in includes/bynder.utils.inc
validateUUID in includes/bynder.utils.inc

File

includes/bynder.utils.inc, line 110
utility functions for the bynder module

Code

function isValid($type, $val) {
  switch ($type) {
    case "uuid":
      return preg_match("/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}\$/", $val);
    case "idHash":
      return preg_match("/[a-f0-9]{16}/", $val);
    case "bynder_drupal_url":
      return preg_match("/.*?(cloudfront\\.net\\/media).*?(" . variable_get('bynder_custom_derivative') . ")/", $val);
    case "id":
      return preg_match("/^[0-9a-f]{16}\$/", $val);
  }
  return true;
}