44.. versionadded :: 2.3 
55    The Isbn constraint was introduced in Symfony 2.3.
66
7+ .. caution ::
8+ 
9+     The ``isbn10 `` and ``isbn13 `` options are deprecated since Symfony 2.5
10+     and will be removed in Symfony 3.0. Use the ``type `` option instead.
11+     Furthermore, when using the ``type `` option, lowercase characters are no
12+     longer supported starting in Symfony 2.5, as they are not allowed in ISBNs.
13+ 
714This constraint validates that an `International Standard Book Number (ISBN) `_
8- is either a valid ISBN-10,  a valid ISBN-13 or both .
15+ is either a valid ISBN-10 or  a valid ISBN-13.
916
1017+----------------+----------------------------------------------------------------------+ 
1118|  Applies to     |  :ref: `property or method<validation-property-target> `                | 
1219+----------------+----------------------------------------------------------------------+ 
13- |  Options        |  - `isbn10 `_                                                           | 
14- |                 |  - `isbn13 `_                                                           | 
20+ |  Options        |  - `type `_                                                             | 
21+ |                 |  - `message `_                                                          | 
1522|                 |  - `isbn10Message `_                                                   | 
1623|                 |  - `isbn13Message `_                                                   | 
1724|                 |  - `bothIsbnMessage `_                                                 | 
@@ -25,7 +32,7 @@ Basic Usage
2532----------- 
2633
2734To use the ``Isbn `` validator, simply apply it to a property or method
28- on an  object that will contain a  ISBN number .
35+ on an  object that will contain an  ISBN.
2936
3037.. configuration-block ::
3138
@@ -36,9 +43,8 @@ on an  object that will contain a ISBN number.
3643            properties : 
3744                isbn : 
3845                    - Isbn : 
39-                         isbn10 : true  
40-                         isbn13 : true  
41-                         bothIsbnMessage : This value is neither a valid ISBN-10 nor a valid ISBN-13.  
46+                         type : isbn10  
47+                         message : This value is not  valid.  
4248
4349code-block :: php-annotations 
4450
@@ -49,9 +55,8 @@ on an  object that will contain a ISBN number.
4955        { 
5056            /** 
5157             * @Assert\Isbn( 
52-              *     isbn10 = true, 
53-              *     isbn13 = true, 
54-              *     bothIsbnMessage = "This value is neither a valid ISBN-10 nor a valid ISBN-13." 
58+              *     type = isbn10, 
59+              *     message: This value is not  valid. 
5560             * ) 
5661             */ 
5762            protected $isbn; 
@@ -63,9 +68,8 @@ on an  object that will contain a ISBN number.
6368        <class  name =" Acme\BookcaseBundle\Entity\Book"  
6469            <property  name =" isbn"  
6570                <constraint  name =" Isbn"  
66-                     <option  name =" isbn10" option > 
67-                     <option  name =" isbn13" option > 
68-                     <option  name =" bothIsbnMessage" option > 
71+                     <option  name =" type" option > 
72+                     <option  name =" message" option > 
6973                </constraint > 
7074            </property > 
7175        </class > 
@@ -85,54 +89,53 @@ on an  object that will contain a ISBN number.
8589            public static function loadValidatorMetadata(ClassMetadata $metadata) 
8690            { 
8791                $metadata->addPropertyConstraint('isbn', new Assert\Isbn(array( 
88-                     'isbn10'          => true, 
89-                     'isbn13'          => true, 
90-                     'bothIsbnMessage' => 'This value is neither a valid ISBN-10 nor a valid ISBN-13.' 
92+                     'type'    => isbn10, 
93+                     'message' => 'This value is not valid.' 
9194                ))); 
9295            } 
9396        } 
9497
9598
9699----------------- 
97100
98- isbn10 
99- ~~~~~~  
101+ type 
102+ ~~~~ 
100103
101- **type **: ``boolean ``
104+ **type **: ``string `` ** default **: `` null ``
102105
103- If this required option is set  to `` true `` the constraint will check if the 
104- code is a valid ISBN-10 code .
106+ The type of ISBN  to validate against. 
107+ Valid values are `` isbn10 ``, `` isbn13 `` and `` null `` to accept any kind of ISBN .
105108
106- isbn13 
107- ~~~~~~ 
109+ message 
110+ ~~~~~~~  
108111
109- **type **: ``boolean ``
112+ **type **: ``string `` ** default **: `` null ``
110113
111- If this required option is set to `` true ``  the constraint will check if the 
112- code is a valid ISBN-13 code .
114+ The message that will be shown if  the value is not valid. 
115+ If not `` null ``, this message has priority over all the other messages .
113116
114117isbn10Message
115118~~~~~~~~~~~~~ 
116119
117120**type **: ``string `` **default **: ``This value is not a valid ISBN-10. ``
118121
119- The message that will be shown if the `isbn10 `_ option is true  and the given
122+ The message that will be shown if the `type `_ option is `` isbn10 ``  and the given
120123value does not pass the ISBN-10 check.
121124
122125isbn13Message
123126~~~~~~~~~~~~~ 
124127
125128**type **: ``string `` **default **: ``This value is not a valid ISBN-13. ``
126129
127- The message that will be shown if the `isbn13 `_ option is true  and the given
130+ The message that will be shown if the `type `_ option is `` isbn13 ``  and the given
128131value does not pass the ISBN-13 check.
129132
130133bothIsbnMessage
131134~~~~~~~~~~~~~~~ 
132135
133136**type **: ``string `` **default **: ``This value is neither a valid ISBN-10 nor a valid ISBN-13. ``
134137
135- The message that will be shown if both  the `isbn10 `_ and ` isbn13 `_ options 
136- are true and the given  value does not pass the ISBN-13 nor  the ISBN-13 check .
138+ The message that will be shown if the `type `_ option is `` null `` and the given 
139+ value does not pass any of  the ISBN checks .
137140
138141.. _`International Standard Book Number (ISBN)` : http://en.wikipedia.org/wiki/Isbn 
0 commit comments