Currency
Edit this pageWarning: You are browsing the documentation for Symfony 2.3, which is no longer maintained.
Read the updated version of this page for Symfony 6.1 (the current stable version).
Currency
2.3
The Currency
constraint was introduced in Symfony 2.3.
Validates that a value is a valid 3-letter ISO 4217 currency name.
Applies to | property or method |
Options | |
Class | Currency |
Validator | CurrencyValidator |
Basic Usage
If you want to ensure that the currency
property of an Order
is
a valid currency, you could do the following:
- Annotations
- YAML
- XML
- PHP
1 2 3 4 5 6 7 8 9 10 11 12
// src/AppBundle/Entity/Order.php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
class Order
{
/**
* @Assert\Currency
*/
protected $currency;
}
This work, including the code samples, is licensed under a
Creative Commons BY-SA 3.0
license.