Commit caabd41
committed
feature #10546 [Validator] Improved ISBN validator (sprain)
This PR was merged into the 2.5-dev branch.
Discussion
----------
[Validator] Improved ISBN validator
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | #10386, #10387, #10542
| License | MIT
| Doc PR | symfony/symfony-docs/pull/3724
This is a new PR of #10542, now on master branch.
Todos:
- [x] Discuss and determine deprecation versions
- [x] Update docs
After following some discussion in the tickets mentioned above I have improved the ISBN validator, which has had some inconsistencies:
* Use a `type` which can be set to `isbn10` or `isbn13` or `null` (checks if value matches any type) instead of the current boolean `isbn10` and `isbn13` options which cause confusion (e.q. if both are true, does this mean the value must match any or both? You could think it's the latter, but that's actually impossible.).
* In the IBAN validator we recently agreed to be strict about upper- and lowercase handling (#10489). Therefore this should be also the case with the ISBN validator. Some ISBN10 numbers may end with an uppercase `X` (representing the check-digit 10), while a lowercase `x` is considered wrong (see [here](http://www.goodreads.com/topic/show/1253500-a-question-about-isbn-10-s---ending-in-x) and [here](http://en.wikipedia.org/wiki/Category:Pages_with_ISBN_errors)). I did not have access to the actual specifications as I have only found documentation which costs about $100 (e.q. [here](http://www.iso.org/iso/catalogue_detail?csnumber=36563)).
To avoid bc breaks I suggest to introduce deprecations for current constraint options. [In the documentation](http://symfony.com/doc/current/contributing/code/conventions.html#deprecations) I haven't found any information about which versions may introduce deprecations, so you might have to help me out here with hints on how to handle it correctly. I'll be happy to provide the code with the deprecated parts removed after that.
Commits
-------
ec42844 Improved ISBN validatorFile tree
Expand file treeCollapse file tree
3 files changed
+95
-44
lines changedOpen diff view settings
Filter options
- src/Symfony/Component/Validator
- Constraints
- Tests/Constraints
Expand file treeCollapse file tree
3 files changed
+95
-44
lines changedOpen diff view settings
Collapse file
src/Symfony/Component/Validator/Constraints/Isbn.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Isbn.php+19-15Lines changed: 19 additions & 15 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
15 | | - |
16 | 15 | |
17 | 16 | |
18 | 17 | |
19 | 18 | |
20 | 19 | |
| 20 | + |
21 | 21 | |
22 | 22 | |
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | | - |
28 | | - |
| 27 | + |
| 28 | + |
29 | 29 | |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
38 | 35 | |
39 | | - |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
40 | 41 | |
41 | | - |
42 | | - |
43 | | - |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
44 | 48 | |
45 | 49 | |
Collapse file
src/Symfony/Component/Validator/Constraints/IsbnValidator.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/IsbnValidator.php+68-23Lines changed: 68 additions & 23 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
16 | 16 | |
17 | 17 | |
18 | 18 | |
19 | | - |
| 19 | + |
20 | 20 | |
21 | 21 | |
22 | | - |
| 22 | + |
23 | 23 | |
24 | 24 | |
25 | 25 | |
| ||
45 | 45 | |
46 | 46 | |
47 | 47 | |
48 | | - |
49 | | - |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
50 | 82 | |
51 | 83 | |
52 | | - |
| 84 | + |
53 | 85 | |
54 | 86 | |
55 | 87 | |
| ||
59 | 91 | |
60 | 92 | |
61 | 93 | |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
| 94 | + |
| 95 | + |
| 96 | + |
67 | 97 | |
68 | | - |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
69 | 109 | |
70 | 110 | |
71 | 111 | |
| ||
74 | 114 | |
75 | 115 | |
76 | 116 | |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
| 117 | + |
88 | 118 | |
89 | | - |
| 119 | + |
90 | 120 | |
91 | 121 | |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | + |
92 | 137 | |
93 | 138 | |
Collapse file
src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php+8-6Lines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
44 | 44 | |
45 | 45 | |
46 | 46 | |
| 47 | + |
47 | 48 | |
48 | 49 | |
49 | 50 | |
| ||
58 | 59 | |
59 | 60 | |
60 | 61 | |
| 62 | + |
61 | 63 | |
62 | 64 | |
63 | 65 | |
| ||
145 | 147 | |
146 | 148 | |
147 | 149 | |
148 | | - |
| 150 | + |
149 | 151 | |
150 | 152 | |
151 | 153 | |
| ||
158 | 160 | |
159 | 161 | |
160 | 162 | |
161 | | - |
| 163 | + |
162 | 164 | |
163 | 165 | |
164 | 166 | |
| ||
172 | 174 | |
173 | 175 | |
174 | 176 | |
175 | | - |
| 177 | + |
176 | 178 | |
177 | 179 | |
178 | 180 | |
| ||
185 | 187 | |
186 | 188 | |
187 | 189 | |
188 | | - |
| 190 | + |
189 | 191 | |
190 | 192 | |
191 | 193 | |
| ||
199 | 201 | |
200 | 202 | |
201 | 203 | |
202 | | - |
| 204 | + |
203 | 205 | |
204 | 206 | |
205 | 207 | |
| ||
212 | 214 | |
213 | 215 | |
214 | 216 | |
215 | | - |
| 217 | + |
216 | 218 | |
217 | 219 | |
218 | 220 | |
|
0 commit comments