New in Symfony 4.3: Improved Financial Constraints
January 3, 2019 • Published by Javier Eguiluz
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
Contributed by
Sylvain Fabre
in #28479.
Matching BIC and IBAN codes
The International Bank Account Number (IBAN) is an internationally agreed system of identifying bank accounts across national borders. The Bank Identifier Code (BIC) is a unique identification code for both financial and non-financial institutions defined in the ISO 9362 standard.
Although both codes are independent, they can be checked in combination to validate that both belong at least to the same country. In Symfony 4.3 we improved the Bic constraint to allow validating BIC and IBAN codes together.
First, you can pass the IBAN code using the new iban
option:
1 2 3 4 5 6 7 8 9
use Symfony\Component\Validator\Constraints as Assert;
// ...
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('businessIdentifierCode', new Assert\Bic([
'iban' => 'FR1420041010050500013M02606',
]));
}
You can also use the new ibanPropertyPath
option to define the object
property that stores the IBAN code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
use Symfony\Component\Validator\Constraints as Assert;
// ...
class Transaction
{
/**
* @Assert\Bic(ibanPropertyPath = "accountNumber")
*/
protected $businessIdentifierCode;
/**
* @Assert\Iban
*/
protected $accountNumber;
// public getters for properties ...
}
Added support for UATP cards
Contributed by
Raúl Fraile
in #29504.
Universal Air Travel Plan (UATP) is the airline owned payment network
accepted by thousands of merchants for air, rail, hotel and travel agency
payments. In Symfony 4.3 we improved the CardScheme constraint to add
support for a new UATP
scheme:
1 2 3 4 5 6 7 8 9 10 11 12
// ...
class Transaction
{
/**
* @Assert\CardScheme(
* schemes={"AMEX", "MASTERCARD", "UATP", "VISA"},
* message="Your credit card number is invalid."
* )
*/
protected $cardNumber;
}
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
now you doing great improvement!
but i think Symfony should be have next version ,something useful.
like https://symfony.com/doc/current/security/form_login_setup.html
with support FormBuilder ready.
will be awesome!