File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ on an object that will contain a credit card number.
54
54
.. code-block :: php-annotations
55
55
56
56
// src/Acme/SubscriptionBundle/Entity/Transaction.php
57
+ namespace Acme\SubscriptionBundle\Entity\Transaction;
58
+
57
59
use Symfony\Component\Validator\Constraints as Assert;
58
60
59
61
class Transaction
@@ -67,16 +69,18 @@ on an object that will contain a credit card number.
67
69
.. code-block :: php
68
70
69
71
// src/Acme/SubscriptionBundle/Entity/Transaction.php
72
+ namespace Acme\SubscriptionBundle\Entity\Transaction;
73
+
70
74
use Symfony\Component\Validator\Mapping\ClassMetadata;
71
- use Symfony\Component\Validator\Constraints\CardScheme ;
75
+ use Symfony\Component\Validator\Constraints as Assert ;
72
76
73
77
class Transaction
74
78
{
75
79
protected $cardNumber;
76
80
77
81
public static function loadValidatorMetadata(ClassMetadata $metadata)
78
82
{
79
- $metadata->addPropertyConstraint('cardSchema ', new CardScheme(array(
83
+ $metadata->addPropertyConstraint('cardNumber ', new Assert\ CardScheme(array(
80
84
'schemes' => array(
81
85
'VISA'
82
86
),
@@ -117,4 +121,4 @@ message
117
121
118
122
The message shown when the value does not pass the ``CardScheme `` check.
119
123
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
Original file line number Diff line number Diff line change 1
1
Luhn
2
- ======
2
+ ====
3
3
4
4
.. versionadded :: 2.2
5
5
The Luhn validation is new in Symfony 2.2.
@@ -49,6 +49,8 @@ will contain a credit card number.
49
49
.. code-block :: php-annotations
50
50
51
51
// src/Acme/SubscriptionBundle/Entity/Transaction.php
52
+ namespace Acme\SubscriptionBundle\Entity\Transaction;
53
+
52
54
use Symfony\Component\Validator\Constraints as Assert;
53
55
54
56
class Transaction
@@ -62,16 +64,18 @@ will contain a credit card number.
62
64
.. code-block :: php
63
65
64
66
// src/Acme/SubscriptionBundle/Entity/Transaction.php
67
+ namespace Acme\SubscriptionBundle\Entity\Transaction;
68
+
65
69
use Symfony\Component\Validator\Mapping\ClassMetadata;
66
- use Symfony\Component\Validator\Constraints\Luhn ;
70
+ use Symfony\Component\Validator\Constraints as Assert ;
67
71
68
72
class Transaction
69
73
{
70
74
protected $cardNumber;
71
75
72
76
public static function loadValidatorMetadata(ClassMetadata $metadata)
73
77
{
74
- $metadata->addPropertyConstraint('luhn ', new Luhn(array(
78
+ $metadata->addPropertyConstraint('cardNumber ', new Assert\ Luhn(array(
75
79
'message' => 'Please check your credit card number',
76
80
)));
77
81
}
@@ -87,4 +91,4 @@ message
87
91
88
92
The default message supplied when the value does not pass the Luhn check.
89
93
90
- .. _`Luhn algorithm` : http://en.wikipedia.org/wiki/Luhn_algorithm
94
+ .. _`Luhn algorithm` : http://en.wikipedia.org/wiki/Luhn_algorithm
You can’t perform that action at this time.
0 commit comments