for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the JVal package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace JVal\Constraint;
use JVal\Context;
use JVal\Types;
use JVal\Walker;
use stdClass;
/**
* Constraint for the "maxItems" keyword.
class MaxItemsConstraint extends AbstractCountConstraint
{
* {@inheritdoc}
public function keywords()
return ['maxItems'];
}
public function supports($type)
return $type === Types::TYPE_ARRAY;
public function apply($instance, stdClass $schema, Context $context, Walker $walker)
if (count($instance) > $schema->maxItems) {
$context->addViolation(
'number of items should be lesser than or equal to %s',
[$schema->maxItems]
);