/** * * @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"; }
/** * 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; }
/** * 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; }
/** * * @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()); }
public function __construct($name, $description = null) { parent::__construct($name, $description); $this->setInputFormatter(new Atrox_Core_Data_Formatter_Trim()); }
/** * * @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}]"; }
public function __construct($name, $description = null) { parent::__construct($name, $description); }
public function __construct($name, $description = null) { parent::__construct($name, $description); $this->addValidator(new Atrox_Core_Data_Validator_Integer()); }
/** * * @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; }
/** * * @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; }