Daniel: The Validator component has some loose documentation here: http://docs.symfony-reloaded.org/guides/validator.html
Additionally, you can find the code of interest here: http://github.com/symfony/symfony/tree/master/src/Symfony/Component/Validator/ Afaik, Bernhard Schussek based Symfony's validation component on JSR-303 (I'm not familiar with it enough to know if there are any major differences). To give a quick run-down, you have a configuration that assigns Constraints (i.e. rules) to fields/ properties of an object. The Validator service, which the Form component uses, will take an object and load the constraint mappings from XML/YML/PHP, and proceed to walk across the object and execute each Constraint against it's paired ConstraintValidator class. One quick note: constraints are simple beans that exist for each mapping, and organize public properties to configure how the constraint should be validated. The ConstraintValidator is more like a service. So if all of your object's properties had NotBlank constraints, a single NotBlankValidator class would be shared. It's stateless in this respect, and this also means we can use it with dependency injection (as the DoctrineUnique validator gets the Entity or DocumentManager instance injected into it). The property path is simply a string that is used to map an error message to the object, and is quite human-readable. "className.foo" would be the property path for an error message on the "foo" property of an object of class "className", and "className.foo[bar]" would mean that index "bar" of the "foo" property had an error. The dot and bracket operators can chain with themselves and each other for deep property paths (like "className.foo.bar.baz"). So once validation completes, we're left with a bunch of property paths and error messages (as the Symfony2 documentation example shows)... and since Symfony2 forms/fields bind/map directly to objects, the Form component can easily determine which error(s) to assign to which field. This also keeps the Form/Validator components nicely de-coupled. Starting in the Validator component, I'd look at the GraphWalker class <http://github.com/symfony/symfony/blob/master/src/Symfony/Component/ Validator/GraphWalker.php> and walkProperty() in particular for an example of how the property path is constructed - you'll notice that method appends a dot and property name to the path as it walks. You won't encounter the bracket operator until Constraints \CollectionValidator <http://github.com/symfony/symfony/blob/master/ src/Symfony/Component/Validator/Constraints/CollectionValidator.php>, since that's the constraint necessary to dive into the elements of arrays. Hope that's a good starting point. I didn't develop any of this (only submitted patches), so if my understanding is off in any way, I hope someone will chime in and correct me :) On Sep 14, 11:54 am, "Daniel A.Tiecher" <[email protected]> wrote: > Thanks fir your answer, Jeremy! > > Wrapping my head around Symfony 2 internals and how the Form and > Validation frameworks work is probably the number of item on my list > to start contributing to the project, yes. > > Can you point me to some documentation or code specifically about this > property path system you mentioned? > > Another question that I got was when you mentioned JSR-303. Symfony 2 > Validation framework is based on that draft or this is something that > would be nice to have? > > I guess that the first thing I'll be doing is contributing with unit > tests to get a feel for the codebase, as well, before tackling some > more complex issues. > > Thanks again for your tips. Really appreciate it! > > On Sep 14, 11:17 am, Jeremy Mikola <[email protected]> wrote: > > > Daniel: > > > There are already a few tickets for forms/valiation > > at:http://trac.symfony-project.org/report/24 > > > If you haven't done so already, I suggest wrapping your head around > > how Validation (and the property path system) works, as it's > > definitely the more complicated component of the two. IMO, the Form > > component isn't too much different than Symfony 1.x (or if it is, it's > > easy to migrate to), but the object-level Validation is completely new > > (for Symfony/PHP at least, it's based on JSR-303). Regarding specific > > fields, I know CollectionField is on the todo list - it's the only > > thing in Forms that isn't working as-is for me, and we're using a > > custom version in the meantime (too many hacks inside to contribute > > upstream at the moment). > > > Perhaps a great step might also be writing unit tests and correcting > > documentation where there may be gaps. Units tests would be good > > practice either way, as any fixes should come paired with a test to > > vouch for the corrected functionality :) > > > Feel free to follow up with any questions (either here or directly). > > > On Sep 13, 9:19 pm, "Daniel A.Tiecher" <[email protected]> wrote: > > > > Hello everybody! > > > > I'm new to this list and got here after Fabien's post on the symfony > > > blog calling for contributors to complete Symfony 2. > > > > What got my interest was the Forms/Validation framework and I would > > > like to know which steps I need to take to at least try to help you > > > guys on this task. > > > > Cheers! -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
