Commit 6ec11533 authored by ver1tas's avatar ver1tas

Changed Assert\MinLength to Assert\Length in doc

parent b356c04f
......@@ -150,7 +150,7 @@ form by adding constraints on the fields::
$form = $app['form.factory']->createBuilder('form')
->add('name', 'text', array(
'constraints' => array(new Assert\NotBlank(), new Assert\MinLength(5))
'constraints' => array(new Assert\NotBlank(), new Assert\Length(array('min' => 5)))
))
->add('email', 'text', array(
'constraints' => new Assert\Email()
......
......@@ -99,10 +99,10 @@ collection of constraints::
);
$constraint = new Assert\Collection(array(
'title' => new Assert\MinLength(10),
'title' => new Assert\Length(array('min' => 10)),
'author' => new Assert\Collection(array(
'first_name' => array(new Assert\NotBlank(), new Assert\MinLength(10)),
'last_name' => new Assert\MinLength(10),
'first_name' => array(new Assert\NotBlank(), new Assert\Length(array('min' => 10))),
'last_name' => new Assert\Length(array('min'=>10),
)),
));
$errors = $app['validator']->validateValue($book, $constraint);
......@@ -133,11 +133,11 @@ the class properties and getters, and then call the ``validate`` method::
$metadata = $app['validator.mapping.class_metadata_factory']->getClassMetadata('Author');
$metadata->addPropertyConstraint('first_name', new Assert\NotBlank());
$metadata->addPropertyConstraint('first_name', new Assert\MinLength(10));
$metadata->addPropertyConstraint('last_name', new Assert\MinLength(10));
$metadata->addPropertyConstraint('first_name', new Assert\Length(array('min' => 10)));
$metadata->addPropertyConstraint('last_name', new Assert\Length(array('min' => 10)));
$metadata = $app['validator.mapping.class_metadata_factory']->getClassMetadata('Book');
$metadata->addPropertyConstraint('title', new Assert\MinLength(10));
$metadata->addPropertyConstraint('title', new Assert\Length(array('min' => 10)));
$metadata->addPropertyConstraint('author', new Assert\Valid());
$errors = $app['validator']->validate($book);
......@@ -163,7 +163,7 @@ You can also declare the class constraint by adding a static
static public function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('title', new Assert\MinLength(10));
$metadata->addPropertyConstraint('title', new Assert\Length(array('min' => 10)));
$metadata->addPropertyConstraint('author', new Assert\Valid());
}
}
......@@ -176,8 +176,8 @@ You can also declare the class constraint by adding a static
static public function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('first_name', new Assert\NotBlank());
$metadata->addPropertyConstraint('first_name', new Assert\MinLength(10));
$metadata->addPropertyConstraint('last_name', new Assert\MinLength(10));
$metadata->addPropertyConstraint('first_name', new Assert\Length(array('min' => 10)));
$metadata->addPropertyConstraint('last_name', new Assert\Length(array('min' => 10)));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment