Пример #1
0
 /**
  * Validate Specification.
  *
  * @param Specification $specification
  *
  * @return Result
  */
 public function validateSpecification(Specification $specification)
 {
     $result = parent::validateSpecification($specification);
     if ($result->isOk() === false) {
         return $result;
     }
     if (is_null($specification->getAttribute('value')) || !in_array($specification->getAttribute('value'), ['yes', 'no'])) {
         return $result->setError(Result::ERROR_VALIDATION_FAILED, 'Specification value should be -yes- or -no-');
     }
     return $result;
 }
Пример #2
0
 /**
  * Validate Specification.
  *
  * @param Specification $specification
  *
  * @return Result
  */
 public function validateSpecification(Specification $specification)
 {
     $result = parent::validateSpecification($specification);
     if ($result->isOk() === false) {
         return $result;
     }
     if (!is_float($specification->getAttribute('value'))) {
         return $result->setError(Result::ERROR_VALIDATION_FAILED, 'Specification value invalid');
     }
     return $result;
 }
Пример #3
0
 /**
  * Validate Specification.
  *
  * @param Specification $specification
  *
  * @return Result
  */
 public function validateSpecification(Specification $specification)
 {
     $result = parent::validateSpecification($specification);
     if ($result->isOk() === false) {
         return $result;
     }
     $value = $specification->getAttribute('value');
     if (!isset($value['start']) || !isset($value['finish']) || !is_numeric($value['start']) || !is_numeric($value['finish'])) {
         return $result->setError(Result::ERROR_VALIDATION_FAILED, 'Specification value invalid');
     }
     return $result;
 }
Пример #4
0
 /**
  * Validate Specification.
  *
  * @param Specification $specification
  *
  * @return Result
  */
 public function validateSpecification(Specification $specification)
 {
     $result = parent::validateSpecification($specification);
     if ($result->isOk() === false) {
         return $result;
     }
     $defaultValueIds = [];
     foreach ($specification->getProperty()->getDefaultValues() as $specValue) {
         $defaultValueIds[] = $specValue->getId();
     }
     foreach ($specification->getAttribute('value') as $defValue) {
         if (!in_array($defValue, $defaultValueIds)) {
             return $result->setError(Result::ERROR_VALIDATION_FAILED, 'Specification value not found in default values');
         }
     }
     return $result;
 }
Пример #5
0
 /**
  * Validate Specification.
  *
  * @param Specification $specification
  *
  * @return Result
  */
 public function validateSpecification(Specification $specification)
 {
     $result = parent::validateSpecification($specification);
     if ($result->isOk() === false) {
         return $result;
     }
     $foundInDefaultValue = false;
     foreach ($specification->getProperty()->getDefaultValues() as $defaultValue) {
         if ($defaultValue->getId() == $specification->getAttribute('value')) {
             $foundInDefaultValue = true;
         }
     }
     if ($foundInDefaultValue === false) {
         return $result->setError(Result::ERROR_VALIDATION_FAILED, 'Specification value not found in default values');
     }
     return $result;
 }