Symfony2 Validator message: Which variables are available?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 03:50:50

If you check out the code for the LengthValidator you posted as an example you can see that these "variables" are just static strings that are replaced inside their own Validator class.

As such, all of them are custom, which is possibly also why there isn't a list available.

The class:

https://github.com/symfony/Validator/blob/master/Constraints/LengthValidator.php

Relevant snippet:

if (null !== $constraint->max && $length > $constraint->max) {
            $this->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->maxMessage)
                ->setParameter('{{ value }}', $this->formatValue($stringValue))
                ->setParameter('{{ limit }}', $constraint->max)
                ->setInvalidValue($value)
                ->setPlural((int) $constraint->max)
                ->setCode(Length::TOO_LONG_ERROR)
                ->addViolation();
            return;
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!