/** * Constructor for the integer validator * * Accepts either a string locale, a Postman_Zend_Locale object, or an array or * Postman_Zend_Config object containing the keys "locale" and/or "format". * * @param string|Postman_Zend_Locale|array|Postman_Zend_Config $options * @throws Postman_Zend_Validate_Exception On empty format */ public function __construct($options = null) { if ($options instanceof Postman_Zend_Config) { $options = $options->toArray(); } if (empty($options)) { require_once 'Zend/Registry.php'; if (Postman_Zend_Registry::isRegistered('Postman_Zend_Locale')) { $this->setLocale(Postman_Zend_Registry::get('Postman_Zend_Locale')); } } elseif (is_array($options)) { // Received if (array_key_exists('locale', $options)) { $this->setLocale($options['locale']); } if (array_key_exists('format', $options)) { $this->setFormat($options['format']); } } elseif ($options instanceof Postman_Zend_Locale || is_string($options)) { // Received Locale object or string locale $this->setLocale($options); } $format = $this->getFormat(); if (empty($format)) { require_once 'Zend/Validate/Exception.php'; throw new Postman_Zend_Validate_Exception("A postcode-format string has to be given for validation"); } }
/** * Sets validator options * * @param string|array|Postman_Zend_Config $options OPTIONAL */ public function __construct($options = array()) { if ($options instanceof Postman_Zend_Config) { $options = $options->toArray(); } else { if (!is_array($options)) { $options = func_get_args(); $temp['format'] = array_shift($options); if (!empty($options)) { $temp['locale'] = array_shift($options); } $options = $temp; } } if (array_key_exists('format', $options)) { $this->setFormat($options['format']); } if (!array_key_exists('locale', $options)) { require_once 'Zend/Registry.php'; if (Postman_Zend_Registry::isRegistered('Postman_Zend_Locale')) { $options['locale'] = Postman_Zend_Registry::get('Postman_Zend_Locale'); } } if (array_key_exists('locale', $options)) { $this->setLocale($options['locale']); } }
/** * Constructor for the float validator * * @param string|Postman_Zend_Config|Postman_Zend_Locale $locale */ public function __construct($locale = null) { if ($locale instanceof Postman_Zend_Config) { $locale = $locale->toArray(); } if (is_array($locale)) { if (array_key_exists('locale', $locale)) { $locale = $locale['locale']; } else { $locale = null; } } if (empty($locale)) { require_once 'Zend/Registry.php'; if (Postman_Zend_Registry::isRegistered('Postman_Zend_Locale')) { $locale = Postman_Zend_Registry::get('Postman_Zend_Locale'); } } $this->setLocale($locale); }