@@ -13,11 +13,11 @@ containing the rules for the validation. Let's validate a simple string
8000
13
13
as an example:
14
14
15
15
use Symfony\Component\Validator\Validation;
16
- use Symfony\Component\Validator\Constraints\MinLength ;
16
+ use Symfony\Component\Validator\Constraints\Length ;
17
17
18
18
$validator = Validation::createValidator();
19
19
20
- $violations = $validator->validateValue('Bernhard', new MinLength(10 ));
20
+ $violations = $validator->validateValue('Bernhard', new Length(array('min' => 10) ));
21
21
22
22
This validation will fail because the given string is shorter than ten
23
23
characters. The precise errors, here called "constraint violations", are
@@ -33,14 +33,14 @@ Validation of arrays is possible using the `Collection` constraint:
33
33
34
34
$constraint = new Assert\Collection(array(
35
35
'name' => new Assert\Collection(array(
36
- 'first_name' => new Assert\MinLength( 101),
37
- 'last_name' => new Assert\MinLength(1 ),
36
+ 'first_name' => new Assert\Length(array('min' => 101) ),
37
+ 'last_name' => new Assert\Length(array('min' => 1) ),
38
38
)),
39
39
'email' => new Assert\Email(),
40
- 'simple' => new Assert\MinLength( 102),
40
+ 'simple' => new Assert\Length(array('min' => 102) ),
41
41
'gender' => new Assert\Choice(array(3, 4)),
42
42
'file' => new Assert\File(),
43
- 'password' => new Assert\MinLength(60 ),
43
+ 'password' => new Assert\Length(array('min' => 60) ),
44
44
));
45
45
46
46
$violations = $validator->validateValue($input, $constraint);
@@ -58,7 +58,7 @@ method results are matched against the constraints.
58
58
class User
59
59
{
60
60
/**
61
- * @Assert\MinLength( 3)
61
+ * @Assert\Length(min = 3)
62
62
* @Assert\NotBlank
63
63
*/
64
64
private $name;
0 commit comments