On Aug 31, 2008, at 4:01 PM, Bernhard Schussek wrote:

>
> Hi!
>
>> Please excuse the ignorance, but does this mean that you'd define  
>> some
>> validation rules in your schema.*ml file?
> Basically yes. You define all rules in the schema files and it doesn't
> matter whether you save a record normally or through a form. It always
> gets validated. If you save it normally, you get an exception thrown,
> and if you save it through a form, the exceptions are caught and
> displayed as error messages.

IMO, the schema file is for defining the database schema- how the ORM  
formats data to and from the database.  The model is responsible for  
handling how the data is modeled.  That includes normalization and  
validation.  It's important to see ALL applicable validators in the  
model definition and not have to figure out what was inherited from a  
schema definition.

Of course, some validators would be inherited by the schema  
definition- max sizes, not null, data type, et al.  These validators  
would be generated as part of the first propel-build-model run (or the  
doctrine equivalent).  It would be extremely obvious how to add more  
validators since they would sit at the top of the model:

// pseudocode using propel syntax;
class DataModel extends BaseDataModel
{
   protected $validators = array(
        new sfNotNullValidator(self::NAME, 'Name is required'), // inherited  
from schema definition
        new sfMinMaxValidator(self::NAME, 3, 30, 'Name must be between 3 and  
30 characters'),
        new sfRegexValidator(self::NAME, '/d+/i', 'Name must be all digits'),
   );

   // rest of the model definition goes here
}

>
>
> The huge benefit is that all rules are defined only once in the
> schema. You don't need to redefine any validators when creating forms,
> and you don't need to validate records manually before saving them.
>
>
> Bernhard
>
>
> On Fri, Aug 29, 2008 at 7:52 PM, Tom Haskins-Vaughan
> <[EMAIL PROTECTED]> wrote:
>>
>> Please excuse the ignorance, but does this mean that you'd define  
>> some
>> validation rules in your schema.*ml file? If so, I think that sounds
>> like a good idea.
>>
>> Jonathan Wage 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]
>>> <mailto:[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] <mailto:[EMAIL PROTECTED]>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Jonathan H. Wage
>>> Open Source Software Developer & Evangelist
>>> http://www.jwage.com
>>>
>>>>
>>
>> --
>> Tom Haskins-Vaughan
>> Temple Street Media: Design and Development for the Web
>> [EMAIL PROTECTED] | www.templestreetmedia.com
>>
>>>
>>
>
> >

--
Jacob Coby
[EMAIL PROTECTED]




--~--~---------~--~----~------------~-------~--~----~
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