/** * {@inheritdoc} */ public function normalize(stdClass $schema, Context $context, Walker $walker) { $context->enterNode('multipleOf'); if (!Types::isA($schema->multipleOf, Types::TYPE_NUMBER)) { throw new InvalidTypeException($context, Types::TYPE_NUMBER); } if ($schema->multipleOf <= 0) { throw new NotStrictlyPositiveException($context); } $context->leaveNode(); }
/** * {@inheritdoc} */ public function apply($instance, stdClass $schema, Context $context, Walker $walker) { if (is_string($schema->type)) { if (!Types::isA($instance, $schema->type)) { $context->addViolation('instance must be of type %s', [$schema->type]); } } else { if (!Types::isOneOf($instance, $schema->type)) { $context->addViolation('instance does not match any of the expected types'); } } }
/** * {@inheritdoc} */ public function normalize(stdClass $schema, Context $context, Walker $walker) { $property = $this->keywords()[0]; $secondaryProperty = $this->keywords()[1]; if (!property_exists($schema, $property)) { throw new MissingKeywordException($context, $property); } if (!property_exists($schema, $secondaryProperty)) { $schema->{$secondaryProperty} = false; } if (!Types::isA($schema->{$property}, Types::TYPE_NUMBER)) { $context->enterNode($property); throw new InvalidTypeException($context, Types::TYPE_NUMBER); } if (!is_bool($schema->{$secondaryProperty})) { $context->enterNode($secondaryProperty); throw new InvalidTypeException($context, Types::TYPE_BOOLEAN); } }