for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Boekkooi\Bundle\JqueryValidationBundle\Form\Rule\Mapping;
use Boekkooi\Bundle\JqueryValidationBundle\Exception\LogicException;
use Boekkooi\Bundle\JqueryValidationBundle\Form\Rule\ConstraintRule;
use Boekkooi\Bundle\JqueryValidationBundle\Form\RuleCollection;
use Boekkooi\Bundle\JqueryValidationBundle\Form\Rule\ConstraintMapperInterface;
use Boekkooi\Bundle\JqueryValidationBundle\Form\RuleMessage;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Iban;
/**
* @author Warnar Boekkooi <[email protected]>
*/
class IbanRule implements ConstraintMapperInterface
{
const RULE_NAME = 'iban';
* @var bool
private $active;
public function __construct($active)
$this->active = $active;
}
* {@inheritdoc}
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
if (!$this->supports($constraint, $form)) {
throw new LogicException();
/** @var Iban $constraint */
$collection->set(
self::RULE_NAME,
new ConstraintRule(
true,
new RuleMessage($constraint->message),
$constraint->groups
)
);
public function supports(Constraint $constraint, FormInterface $form)
return $this->active && get_class($constraint) === Iban::class;