> IMO, the schema file is for defining the database schema- how the
ORM
> formats data to and from the database.
For Doctrine, that is not the case. Here the schema.yml is just a
generator decription for generating the model classes. All the
definitions are written into these model classes, you can as well write
them yourself without using a schema.yml file at all.
Custom validators are definitions just like "type" or "length", except
for that they are boolean values that are set to TRUE if you want to use
the validator for a column.
DataModel:
columns:
name:
# native definitions
type: string
length: 255
# custom validators (already exist in Doctrine)
notnull: true
email: true
Considering error messages, I think if a validator is specific enough
(which it usually should be), the error message can be coded in the
validator with the option to override it.
Bernhard
Am Sonntag, den 31.08.2008, 18:17 -0400 schrieb Jacob Coby:
> 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
-~----------~----~----~----~------~----~------~--~---