Hello all,

> I think it would be nice to be able to control validation at the model level
> and be able to inherit those rules to be used on the actions on the frontend
> of the application. Currently I find myself duplicating things at the model
> layer and symfony validation layer.
I totally agree. I have already thought about this problem a little
and will try to provide a sample implementation for sfDoctrinePlugin.
What I basically want to do is to replace Doctrine's validation layer
by symfony's sfValidatorSchema. As far as I saw in the code right now,
this should be perfectly possible.

In the end it should work like this: Calling $record->save() throws an
sfErrorSchema if the record is invalid. sfFormDoctrine::bindAndSave()
is able to catch this schema and display the errors. bindAndSave()
(which could be renamed to bind() IMO) could also execute the
validators of the form itself and combine the two error schemas. The
only question is how to execute both validations without saving the
record if the form-level validation fails. For this to work, record
validation should maybe be done in $record->validate() which returns
an sfErrorSchema (that is in the end thrown by save()).

With this implementation, saving a record in an action or saving a
record through a form both use the same validation layer.
Additionally, you get very descriptive error messages (sfErrorSchema)
thrown when you save an invalid record. Right now, Doctrine just
notifies you whether all records were valid.

If my implementation works as I expect it to, I would really like to
see it included in sfDoctrinePlugin. My goal is to make this
implementation 100% compatible with Doctrine's schema/record
definition syntax, so users can still look up in Doctrine's
documentation while using a more sophisticated validation mechanism in
the background.


Bernhard


On Fri, Aug 29, 2008 at 7:44 PM, Jonathan Wage <[EMAIL PROTECTED]> wrote:
> I think it would be nice to be able to control validation at the model level
> and be able to inherit those rules to be used on the actions on the frontend
> of the application. Currently I find myself duplicating things at the model
> layer and symfony validation layer.
>
> - Jon
>
> On Fri, Aug 29, 2008 at 11:00 AM, Jacob Coby <[EMAIL PROTECTED]> wrote:
>>
>> All,
>>
>> During today's #symfony-sprint, the topic of model-level validation
>> similar to Django or RoR came up.  I'm curious to see what everyone's
>> opinion is.  Is it worth pursuing in 1.3?
>>
>> --
>> Jacob Coby
>> [EMAIL PROTECTED]
>>
>>
>>
>>
>>
>
>
>
> --
> Jonathan H. Wage
> Open Source Software Developer & Evangelist
> http://www.jwage.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
-~----------~----~----~----~------~----~------~--~---

Reply via email to