Beispiel #1
0
 /**
  *
  * @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";
 }
Beispiel #2
0
 /**
  * Called in setup to define the shape of this entity.
  *
  * @see setup
  *
  * @throws Atrox_Core_Data_Exception_DuplicatePropertyException If this entity already has the property
  *
  * @param Atrox_Core_Data_Property $property
  *
  * @return Atrox_Core_Data_Property
  */
 public function addProperty(Atrox_Core_Data_Property $property)
 {
     $propertyName = $property->getName();
     if (isset($this->properties[$propertyName])) {
         throw new Atrox_Core_Data_Exception_DuplicatePropertyException("'{$propertyName}' is already defined for this Entity");
     }
     $this->properties[$propertyName] = $property;
     return $property;
 }
Beispiel #3
0
 /**
  * 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;
 }
Beispiel #4
0
 /**
  *
  * @param Atrox_Core_Data_Property $property
  * @return string
  */
 public function parseProperty(Atrox_Core_Data_Property $property)
 {
     return $this->parseTable($property->getDataSource()->getTableName()) . "." . $this->parseField($property->getName());
 }
Beispiel #5
0
 public function __construct($name, $description = null)
 {
     parent::__construct($name, $description);
     $this->setInputFormatter(new Atrox_Core_Data_Formatter_Trim());
 }
Beispiel #6
0
 /**
  *
  * @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}]";
 }
Beispiel #7
0
 public function __construct($name, $description = null)
 {
     parent::__construct($name, $description);
 }
Beispiel #8
0
 public function __construct($name, $description = null)
 {
     parent::__construct($name, $description);
     $this->addValidator(new Atrox_Core_Data_Validator_Integer());
 }
Beispiel #9
0
 /**
  *
  * @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;
 }
Beispiel #10
0
 /**
  *
  * @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;
 }