* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Intl\Intl; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * Validates whether a value is a valid currency. * * @author Miha Vrhovnik * @author Bernhard Schussek */ class CurrencyValidator extends ConstraintValidator { /** * {@inheritdoc} */ public function validate($value, Constraint $constraint) { if (!$constraint instanceof Currency) { throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Currency'); } if (null === $value || '' === $value) { return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedTypeException($value, 'string'); } $value = (string) $value; $currencies = Intl::getCurrencyBundle()->getCurrencyNames(); if (!isset($currencies[$value])) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) ->setCode(Currency::NO_SUCH_CURRENCY_ERROR) ->addViolation(); } } } __halt_compiler();----SIGNATURE:----EgitPLNMZ9qISoyQGHDjX5IlZm7FcT+Y5JGPpxemrYOJJQMWqhWqyFVQGRlxva44pIXN79uLOs9cTMYCtvt0T455CKg+AAVESUO3RYjpq4U53aPwnDUaumtoVmiWGl+JQeyxCVV6wTxU69xUpF23gt+jtxUTsFywiJhLfDKYMNL/OSuGcUAC0bZePh4hW3/sFExeCEVJjwJ88K/zmkEZo2tRiQdKLKMM1+QEd9yrI/yQAbA92hRoKvX1h/8+Nj2dr9FkohN++yNESF+qVTjd1Mx8kqLMqwNaH1Fk8macI5PxPcIV7kOfoA/ruhP2sW92prh35cWASMUe+KfhXns6p1G3cbttFPEkNBoad7tmo473pwgNX3aRFUIwya8p4r3hEn2o4ZRNfCzItm7PJFITSu0fGU0CfOTPgg6WdsrEXS0hL27IrPUl3+E5zxigTO+e1DEJmGuPG461kiHrJqYPRoiHmngtsIelfm0cDHQeOs9X/mKMXLfm3m2wPD9HVlB7/O6rJ8eWYslolpN4Xh3fSVg2cpUZHSoAf5y4xbhTlzJrOXDOSOp3vjygn+cyM3T3MDv0ajrwHCKf59JW6Dbej7QrMEBbnzb2eSTLdy5kvZqGTY4eXKRvWeHJjnHYagAOJbEJCXlKWtJXhdUq2B/uisW4d5PxZgofesTwCXJiMl8=----ATTACHMENT:----MzAwNzQ3NjU1NjU3MzY4OSA5Mjc3Njc4MTQ4MTAxNjcwIDMwNjI5MzE3MDMxNjUzMzQ=