You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To 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.
29
36
30
37
.. configuration-block::
31
38
@@ -36,9 +43,8 @@ on an object that will contain a ISBN number.
36
43
properties:
37
44
isbn:
38
45
- 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.
42
48
43
49
.. code-block:: php-annotations
44
50
@@ -49,9 +55,8 @@ on an object that will contain a ISBN number.
49
55
{
50
56
/**
51
57
* @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.
55
60
* )
56
61
*/
57
62
protected $isbn;
@@ -63,9 +68,8 @@ on an object that will contain a ISBN number.
63
68
<classname="Acme\BookcaseBundle\Entity\Book">
64
69
<propertyname="isbn">
65
70
<constraintname="Isbn">
66
-
<optionname="isbn10">true</option>
67
-
<optionname="isbn13">true</option>
68
-
<optionname="bothIsbnMessage">This value is neither a valid ISBN-10 nor a valid ISBN-13.</option>
71
+
<optionname="type">isbn10</option>
72
+
<optionname="message">This value is not valid.</option>
69
73
</constraint>
70
74
</property>
71
75
</class>
@@ -85,54 +89,53 @@ on an object that will contain a ISBN number.
85
89
public static function loadValidatorMetadata(ClassMetadata $metadata)
86
90
{
87
91
$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.'
91
94
)));
92
95
}
93
96
}
94
97
95
98
Available Options
96
99
-----------------
97
100
98
-
isbn10
99
-
~~~~~~
101
+
type
102
+
~~~~
100
103
101
-
**type**: ``boolean``
104
+
**type**: ``string`` **default**: ``null``
102
105
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.
105
108
106
-
isbn13
107
-
~~~~~~
109
+
message
110
+
~~~~~~~
108
111
109
-
**type**: ``boolean``
112
+
**type**: ``string`` **default**: ``null``
110
113
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.
113
116
114
117
isbn10Message
115
118
~~~~~~~~~~~~~
116
119
117
120
**type**: ``string`` **default**: ``This value is not a valid ISBN-10.``
118
121
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
120
123
value does not pass the ISBN-10 check.
121
124
122
125
isbn13Message
123
126
~~~~~~~~~~~~~
124
127
125
128
**type**: ``string`` **default**: ``This value is not a valid ISBN-13.``
126
129
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
128
131
value does not pass the ISBN-13 check.
129
132
130
133
bothIsbnMessage
131
134
~~~~~~~~~~~~~~~
132
135
133
136
**type**: ``string`` **default**: ``This value is neither a valid ISBN-10 nor a valid ISBN-13.``
134
137
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.
137
140
138
141
.. _`International Standard Book Number (ISBN)`: http://en.wikipedia.org/wiki/Isbn
0 commit comments