Example #1
0
 protected function applyValue($input, Context $ctx)
 {
     $valid = false;
     foreach ($this->checks as $id => $check) {
         $newCtx = new Context();
         $input = $check->apply($input, $newCtx);
         $flat = $newCtx->flatten();
         if ($flat->valid) {
             $valid = $flat->valid;
             if ($change = $flat->change) {
                 $ctx->setChange($change);
             }
             if (!$flat->complete) {
                 $ctx->setIncomplete($this);
             }
             break;
         }
     }
     if (!$valid) {
         $ctx->addReason($this, ['id' => 'any.invalid']);
     }
     return $input;
 }
Example #2
0
 function apply($input, Context $ctx)
 {
     $ctx->setIncomplete($this);
     return $input;
 }
Example #3
0
 function validate(array $input, Context $ctx)
 {
     $ctx->setIncomplete($this);
 }
Example #4
0
 private function compareString(Context $ctx, $left, $right)
 {
     if (is_string($left) && is_string($right)) {
         if (static::$intlAvailable) {
             if ($this->test(\Normalizer::normalize($left) != \Normalizer::normalize($right))) {
                 $ctx->addReason($this, ['id' => 'equal.stringNotEqual', 'params' => $properties]);
             }
         } else {
             $ctx->setIncomplete($this);
         }
     } else {
         $ctx->addReason($this, ['id' => 'equal.incomparable', 'params' => ['leftProp' => $this->left, 'rightProp' => $this->right]]);
     }
     return;
 }