コード例 #1
0
 /**
  * @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);
     });
 }
コード例 #2
0
 /**
  * @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));
     }
 }
コード例 #3
0
 /**
  * @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));
     }
 }
コード例 #4
0
 /**
  * @param ...$arguments
  * @return $this
  */
 public function valid(...$arguments)
 {
     $this->assert(new Assertions\InArray(['allowed' => Utils::variadicToArray($arguments)]));
     return $this;
 }
コード例 #5
0
 /**
  * @return $this
  */
 public function any()
 {
     $this->assert(new Assertions\AlternativeAny(['options' => Utils::variadicToArray(func_get_args())]));
     return $this;
 }
コード例 #6
0
ファイル: AnySchema.php プロジェクト: sanjiisan/validation
 /**
  * @return $this
  */
 public function valid()
 {
     $this->assert(new Assertions\InArray(['allowed' => Utils::variadicToArray(func_get_args())]));
     return $this;
 }
コード例 #7
0
 /**
  * @return \Closure
  */
 protected function provideVariadicFunction()
 {
     return function () {
         return Utils::variadicToArray(func_get_args());
     };
 }
コード例 #8
0
 /**
  * @param ...$arguments
  * @return $this
  */
 public function any(...$arguments)
 {
     $this->assert(new Assertions\AlternativeAny(['options' => Utils::variadicToArray($arguments)]));
     return $this;
 }