/**
  * @param Property $property
  * @param Requirement $requirement
  * @param $value
  * @return RequirementValidationException
  */
 public static function make(Property $property, Requirement $requirement, $value)
 {
     $e = new self('Validation exception for property ' . $property->getPropertyName());
     $e->property = $property;
     $e->requirement = $requirement;
     $e->value = $value;
     return $e;
 }
Ejemplo n.º 2
0
 /**
  * @param Property $property
  * @param $value
  * @return mixed
  * @throws RequirementValidationException
  */
 public function validate(Property $property, $value)
 {
     if ($value === null) {
         return;
     }
     if (PropertyType::isNumeric($property->getType())) {
         if ($value > $this->length) {
             throw RequirementValidationException::make($property, $this, $value);
         }
     } else {
         if (mb_strlen($value) > $this->length) {
             throw RequirementValidationException::make($property, $this, $value);
         }
     }
 }