Skip to content

Commit e3ed397

Browse files
committed
Improved CardScheme validator doc
Based on feedback from @wouterj on the Iban validator doc. See symfony#2521
1 parent 33ba23b commit e3ed397

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

reference/constraints/CardScheme.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ on an object that will contain a credit card number.
5454
.. code-block:: php-annotations
5555
5656
// src/Acme/SubscriptionBundle/Entity/Transaction.php
57+
namespace Acme\SubscriptionBundle\Entity\Transaction;
58+
5759
use Symfony\Component\Validator\Constraints as Assert;
5860
5961
class Transaction
@@ -67,16 +69,18 @@ on an object that will contain a credit card number.
6769
.. code-block:: php
6870
6971
// src/Acme/SubscriptionBundle/Entity/Transaction.php
72+
namespace Acme\SubscriptionBundle\Entity\Transaction;
73+
7074
use Symfony\Component\Validator\Mapping\ClassMetadata;
71-
use Symfony\Component\Validator\Constraints\CardScheme;
75+
use Symfony\Component\Validator\Constraints as Assert;
7276
7377
class Transaction
7478
{
7579
protected $cardNumber;
7680
7781
public static function loadValidatorMetadata(ClassMetadata $metadata)
7882
{
79-
$metadata->addPropertyConstraint('cardSchema', new CardScheme(array(
83+
$metadata->addPropertyConstraint('cardNumber', new Assert\CardScheme(array(
8084
'schemes' => array(
8185
'VISA'
8286
),
@@ -117,4 +121,4 @@ message
117121

118122
The message shown when the value does not pass the ``CardScheme`` check.
119123

120-
.. _`Wikipedia: Issuer identification number (IIN)`: http://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number_.28IIN.29
124+
.. _`Wikipedia: Issuer identification number (IIN)`: http://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number_.28IIN.29

0 commit comments

Comments
 (0)