/**
  * @param InputValue $input
  * @throws ValidationException
  */
 public function process(InputValue $input)
 {
     if ($this->getOption('convert') === false && !$input->getValue() instanceof \DateTime) {
         throw new ValidationException('value is not a DateTime object');
     }
     $input->replace(function ($value) {
         return Utils::toDateObject($value);
     });
 }
 /**
  * @param InputValue $input
  * @throws ValidationException
  */
 public function process(InputValue $input)
 {
     $isDate = new IsDate();
     $isDate->process($input);
     $date = Utils::toDateObject($input->getValue());
     $toCompare = $this->getOption('time');
     if ($date >= $toCompare) {
         throw new ValidationException('Date should be before ' . $toCompare->format(\DateTime::ISO8601));
     }
 }
 /**
  * @param InputValue $input
  * @throws ValidationException
  */
 public function process(InputValue $input)
 {
     $isDate = new IsDate();
     $isDate->process($input);
     $date = Utils::toDateObject($input->getValue());
     $time1 = $this->getOption('time1');
     $time2 = $this->getOption('time2');
     if ($date < $time1 || $date > $time2) {
         throw new ValidationException('Date should be between ' . $time1->format(\DateTime::ISO8601) . ' and ' . $time2->format(\DateTime::ISO8601));
     }
 }
 /**
  * @param ...$arguments
  * @return $this
  */
 public function valid(...$arguments)
 {
     $this->assert(new Assertions\InArray(['allowed' => Utils::variadicToArray($arguments)]));
     return $this;
 }
 /**
  * @return $this
  */
 public function any()
 {
     $this->assert(new Assertions\AlternativeAny(['options' => Utils::variadicToArray(func_get_args())]));
     return $this;
 }
示例#6
0
 /**
  * @return $this
  */
 public function valid()
 {
     $this->assert(new Assertions\InArray(['allowed' => Utils::variadicToArray(func_get_args())]));
     return $this;
 }
 /**
  * @return \Closure
  */
 protected function provideVariadicFunction()
 {
     return function () {
         return Utils::variadicToArray(func_get_args());
     };
 }
 /**
  * @param ...$arguments
  * @return $this
  */
 public function any(...$arguments)
 {
     $this->assert(new Assertions\AlternativeAny(['options' => Utils::variadicToArray($arguments)]));
     return $this;
 }