for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace FlexPHP\Schema\Validators;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Regex;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validation;
/**
* @Annotation
*/
class PropertyNameValidator
{
* @var integer
private $minLength = 1;
private $maxLength = 64;
public function validate(string $name): ConstraintViolationListInterface
$validator = Validation::createValidator();
return $validator->validate($name, [
new NotBlank(),
new Length([
'min' => $this->minLength,
'max' => $this->maxLength,
]),
new Regex([
'pattern' => '/^[a-zA-Z_][a-zA-Z0-9_]*$/',
]);
}