コード例 #1
0
ファイル: Unique.php プロジェクト: serby/Atrox
 /**
  *
  * @see Core/Data/Atrox_Core_Data_IValidator#validate($value)
  */
 public function validate($value, Atrox_Core_Data_Property $property)
 {
     $dataSource = $property->getDataSource();
     $filter = $property->getDataSource()->makeFilter();
     $filter->addConditional($dataSource->getTableName(), $property->getName(), $value);
     $count = $dataSource->count($filter);
     return $count <= 1 ? true : "'" . $property->getDescription() . "' must be unique. '{$value}' is already used";
 }
コード例 #2
0
ファイル: StrongPassword.php プロジェクト: serby/Atrox
 /**
  * Validate $password making sure it is Strong
  * A strong password is any password greater than $minLength which has at
  * least 1 alphabet character and one number or symbol in it
  * @see Core/Data/Atrox_Core_Data_IValidator#validate($value)
  * @param string $password The value to validate
  * @return bool True if $value is a strong password
  */
 public function validate($value, Atrox_Core_Data_Property $property)
 {
     $password = trim($value);
     $length = mb_strlen($value);
     if ($length < $this->minimumLength) {
         return false;
     }
     $charFound = false;
     $digitFound = false;
     for ($i = 0; $i < $length; $i++) {
         $c = ord(mb_substr($value, $i, 1));
         if ($c >= 65 && $c <= 90 || $c >= 97 && $c <= 122) {
             $charFound = true;
         }
         if ($c >= 48 && $c <= 57) {
             $digitFound = true;
         }
         if ($digitFound && $charFound) {
             return "'" . $property->getDescription() . "' must be a mixture of numbers and letters";
         }
     }
     return true;
 }
コード例 #3
0
ファイル: Integer.php プロジェクト: serby/Atrox
 /**
  *
  * @see Core/Data/Atrox_Core_Data_IValidator#validate($value)
  */
 public function validate($value, Atrox_Core_Data_Property $property)
 {
     return empty($value) || is_numeric($value) && $value == (int) $value ? true : "'" . $property->getDescription() . "' must be a whole number [{$value}]";
 }
コード例 #4
0
ファイル: MaxLength.php プロジェクト: serby/Atrox
 /**
  *
  * @see Core/Data/Atrox_Core_Data_IValidator#validate($value)
  */
 public function validate($value, Atrox_Core_Data_Property $property)
 {
     return strlen($value) > $this->maximumLength ? "'" . $property->getDescription() . "' must not exceed {$this->maximumLength} charaters" : true;
 }
コード例 #5
0
ファイル: Required.php プロジェクト: serby/Atrox
 /**
  *
  * @see Core/Data/Atrox_Core_Data_IValidator#validate($value)
  */
 public function validate($value, Atrox_Core_Data_Property $property)
 {
     return $value !== false && empty($value) ? "'" . $property->getDescription() . "' is required" : true;
 }