for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace ApiPlatform\Core\Bridge\Symfony\Validator\Metadata\Property\Restriction;
use ApiPlatform\Core\Metadata\Property\PropertyMetadata;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Regex;
/**
* Class PropertySchemaRegexRestriction.
* @author Andrii Penchuk [email protected]
class PropertySchemaRegexRestriction implements PropertySchemaRestrictionMetadataInterface
{
* {@inheritdoc}
public function create(Constraint $constraint, PropertyMetadata $propertyMetadata): array
return isset($constraint->pattern) ? ['pattern' => $constraint->pattern] : [];
}
public function supports(Constraint $constraint, PropertyMetadata $propertyMetadata): bool
return $constraint instanceof Regex && $constraint->match;