File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed 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