Example #1
0
 /**
  * Construct specification based on validators list
  * @param array $validators
  * @return SpecificationInterface|false
  * @throws \Exception
  */
 protected function getFieldSpecification($validators)
 {
     /** @var SpecificationInterface $spec */
     $spec = false;
     foreach ($validators as $validatorName => $validatorParams) {
         $currentValidator = SpecificationFactory::getSpecification($validatorName, $validatorParams);
         if ($spec) {
             $spec = $spec->plus($currentValidator);
         } else {
             $spec = $currentValidator;
         }
     }
     return $spec;
 }
 /**
  * @param bool $expected
  * @param mixed $value
  * @dataProvider rangeProvider
  */
 public function testRangeValidator($expected, $value)
 {
     $field = SpecificationFactory::getSpecification('Range', ['min' => 2, 'max' => 5]);
     $this->assertEquals($expected, $field->isSatisfiedBy($value));
 }