Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for annotation based validations for entities #55

Closed
wowo opened this issue Feb 28, 2011 · 7 comments
Closed

Support for annotation based validations for entities #55

wowo opened this issue Feb 28, 2011 · 7 comments

Comments

@wowo
Copy link

wowo commented Feb 28, 2011

I have validation rules in annotations like @Validation:MinLength(3), but BaseApplication forms don't handle them at all. It's extremaly useful to use this way of validation.

@rande
Copy link
Member

rande commented Feb 28, 2011

The validation is done by the Validation framework. Nothing to do with this bundle.

@Pop-Code
Copy link

So how we must use it ? is there some docs ?

@rande
Copy link
Member

rande commented Nov 14, 2011

@Pop-Code
Copy link

Thanks, i saw that my group validator was not the good one, now it works.

But i got error on UniqueValidator, how to impletment unique to work with admin ?

@ghost
Copy link

ghost commented Feb 28, 2013

@AHWEBDEV, i have the same problem with unique validation.. had you found any answer?

@Pop-Code
Copy link

@p-shad you must use the annotation on the class annotation it self

An example, i use it to force my "page" entity to be unique based on the slug property.

use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;

/**
 * @ORM\Table(name="pages")
 * @ORM\Entity
 * @DoctrineAssert\UniqueEntity(fields="slug", message="A page with same slug already exists", groups={"admin"})
 */
class Pages
{
[...]
}

Also when you valid the entity, via a form validator or entity validator, you must specify the group of validation.
In this case, "admin" is the group defined in the annotation.

This doc can be useful. http://symfony.com/doc/current/reference/constraints/UniqueEntity.html
Check for your symfony2 version.

@ghost
Copy link

ghost commented Mar 2, 2013

@AHWEBDEV ,thanks!that works! i think that we should define validation group..

tashanta pushed a commit to tashanta/SonataAdminBundle that referenced this issue Aug 5, 2013
…ation_fix

Loading information message fix
ft-1408 pushed a commit to intexsys/SonataAdminBundle that referenced this issue Sep 17, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants