/** * Constructor sets-up the validation rule with a descriptive name for this * validator, an optional Encoder instance (for canonicalization) and an * optional date format string. The date format string should be of the type * accepted by PHP's date() function. * * @param string $typeName A descriptive name for this validator. * @param Encoder $encoder Encoder object providing canonicalize method. * @param string $newFormat Date format string {@see date()}. */ public function __construct($typeName, $encoder = null, $newFormat = null) { parent::__construct($typeName, $encoder); if (!is_string($newFormat) || $newFormat == '') { $newFormat = 'Y-m-d'; } $this->setDateFormat($newFormat); }
/** * Constructor sets-up the validation rule with a descriptive name for this * validator, an optional Encoder instance (for canonicalization) and an * optional instance of a ValidationRule implementation for validating * Credit Card Numbers. * * @param string $typeName descriptive name for this validator. * @param object $encoder Encoder providing canonicalize method. * @param object $validationRule instance of a ValidationRule * implementation for validating Credit * Card Numbers. * * @return does not return a value. */ public function __construct($typeName, $encoder = null, $validationRule = null) { parent::__construct($typeName, $encoder); if ($validationRule instanceof ValidationRule) { $this->ccrule = $validationRule; } else { $this->ccrule = $this->_getCCRule(); } }
/** * Constructor sets-up the validation rule with a descriptive name for this * validator, an optional Encoder instance (for canonicalization) and an * optional whitelist regex pattern. * * @param string $typeName descriptive name for this validator. * @param object $encoder providing canonicalize method. * @param string $whiteListPattern Whitelist regex. * * @return does not return a value */ public function __construct($typeName, $encoder = null, $whiteListPattern = null) { parent::__construct($typeName, $encoder); $this->whitelistPatterns = array(); $this->blacklistPatterns = array(); if (is_string($whiteListPattern)) { $this->addWhitelistPattern($whiteListPattern); } elseif ($whiteListPattern !== null) { throw new InvalidArgumentException('Validation misconfiguration - constructor expected a string' . ' $whiteListPattern'); } }
/** * Constructor sets-up the validation rule with a descriptive name for this * validator, an optional Encoder instance (for canonicalization) and * optional minimum and maximum bounds for valid integers. * * @param string $typeName Descriptive name for this validator. * @param object $encoder providing canonicalize method. * @param int $minValue minimum valid number. * @param int $maxValue maximum valid number. * * @return does not return a value. */ public function __construct($typeName, $encoder, $minValue = null, $maxValue = null) { parent::__construct($typeName, $encoder); if ($minValue === null || !is_numeric($minValue)) { $this->_minValue = 1 - PHP_INT_MAX; } else { $this->_minValue = (int) $minValue; } if ($maxValue === null || !is_numeric($maxValue)) { $this->_maxValue = PHP_INT_MAX; } else { $this->_maxValue = (int) $maxValue; } }