@@ -822,9 +822,13 @@ With this configuration, there are three validation groups:
822
822
fields only.
823
823
824
824
To tell the validator to use a specific group, pass one or more group names
825
- as the second argument to the ``validate() `` method::
825
+ as the third argument to the ``validate() `` method::
826
826
827
- $errors = $validator->validate($author, array('registration'));
827
+ // If you're using the new 2.5 validation API (you probably are!)
828
+ $errors = $validator->validate($author, null, array('registration'));
829
+
830
+ // If you're using the old 2.4 validation API
831
+ // $errors = $validator->validate($author, array('registration'));
828
832
829
833
If no groups are specified, all constraints that belong in group ``Default ``
830
834
will be applied.
@@ -1189,10 +1193,19 @@ it looks like this::
1189
1193
$emailConstraint->message = 'Invalid email address';
1190
1194
1191
1195
// use the validator to validate the value
1196
+ // If you're using the new 2.5 validation API (you probably are!)
1197
+ $errorList = $this->get('validator')->validate(
1198
+ $email,
1199
+ $emailConstraint
1200
+ );
1201
+
1202
+ // If you're using the old 2.4 validation API
1203
+ /*
1192
1204
$errorList = $this->get('validator')->validateValue(
1193
1205
$email,
1194
1206
$emailConstraint
1195
1207
);
1208
+ */
1196
1209
1197
1210
if (count($errorList) == 0) {
1198
1211
// this IS a valid email address, do something
@@ -1206,13 +1219,13 @@ it looks like this::
1206
1219
// ...
1207
1220
}
1208
1221
1209
- By calling ``validateValue `` on the validator, you can pass in a raw value and
1222
+ By calling ``validate `` on the validator, you can pass in a raw value and
1210
1223
the constraint object that you want to validate that value against. A full
1211
1224
list of the available constraints - as well as the full class name for each
1212
1225
constraint - is available in the :doc: `constraints reference </reference/constraints >`
1213
1226
section .
1214
1227
1215
- The ``validateValue `` method returns a :class: `Symfony\\ Component\\ Validator\\ ConstraintViolationList `
1228
+ The ``validate `` method returns a :class: `Symfony\\ Component\\ Validator\\ ConstraintViolationList `
1216
1229
object, which acts just like an array of errors. Each error in the collection
1217
1230
is a :class: `Symfony\\ Component\\ Validator\\ ConstraintViolation ` object,
1218
1231
which holds the error message on its ``getMessage `` method.
0 commit comments