for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace JBen87\ParsleyBundle\Constraint\Constraints;
use JBen87\ParsleyBundle\Constraint\Constraint;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class MaxLength extends Constraint
{
/**
* @var int
*/
private $max;
* @param array $options
public function __construct(array $options = [])
parent::__construct($options);
$this->max = $options['max'];
}
* @inheritdoc
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = []): array
return parent::normalize($normalizer, $format, $context) + ['maxlength' => $this->getValue()];
protected function getAttribute(): string
return 'data-parsley-maxlength';
protected function getValue(): string
return (string) $this->max;
protected function configureOptions(OptionsResolver $resolver): void
$resolver
->setRequired(['max'])
->setAllowedTypes('max', ['int'])
;