Hi Eus,

If I may point you to an earlier thread about this topic:
http://groups.google.com/group/symfony-devs/browse_thread/thread/c4da14959aa6e5d7/afe01c41b79dd2b3?lnk=gst&q=model+based#afe01c41b79dd2b3


Bernhard


On Tue, Nov 11, 2008 at 10:19 AM, Eus <[EMAIL PROTECTED]> wrote:
>
> Hi Ho!
>
> From a given schema of a DB, a set of basic restrictions for all fields can 
> be concluded. For example, if a field is designated as a PK, automatically 
> its value must be unique. Another example, if a field is of type VARCHAR(10), 
> it can only accommodate 10 characters at most.
>
> Currently, symfony does not validate user input for the fields against such 
> basic restrictions automatically. For example, for a field named `a_field' of 
> type VARCHAR(10), it is needed to write something like:
>
>  product{a_field}:
>    sfStringValidator:
>      max: 15
>      max_error: Can only contain 15 characters
>
> This needs to be repeated in every other modules that also provide CRUD for 
> the field.
>
> Since a failure to validate such basic restrictions of the model will result 
> in a PropelException like:
>
> [PropelException]
> Unable to execute INSERT statement. [wrapped: Could not execute update 
> [Native Error: ERROR: value too long for type character varying(15)]
>
> symfony should automatically generate one class for each table that will act 
> as the validator of basic restrictions of the fields of the table.
>
> These classes then can be _overridden_ by users that need further checking 
> such as lapse year in case of a date field, and can be _complemented_ with 
> `validate/*.yml'.
>
> If database schema itself cannot be deduced from the live DB, a simple .yml 
> file may be provided to help symfony generates the classes. For example,
>
> table_a:
>  field_a:
>    varchar: 5
>
> What do you think?
>
> Also, currently I would like to implement such a facility so that I do not 
> have to clutter myself with the validations of the basic restrictions of each 
> table. Anyone would like to provide suggestion as how the things should be 
> hacked?
>
> Thank you.
>
> Best regards,
> Eus
>
>
>
>
> >
>

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