Yii Framework Forum: Changes and new features for CModel - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Changes and new features for CModel

#41 User is offline   mindplay 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 397
  • Joined: 03-September 09
  • Location:New York

Posted 02 September 2011 - 09:13 AM

View Postkernel, on 27 August 2011 - 07:05 AM, said:

Rules / validators should be an independent part not only it can be used by model but also in general purpose, There could be 2 layers - 1, rule and 2, ruleset.


That is an interesting point.

The ability to construct a "state validator" (e.g. set of rules) and apply that validation to different objects, would be an interesting feature - for one, if you could compartmentalize validation rules in this way, you could apply certain validations both to a form and to a model object. You could also easily reuse a set of validations between different models, explicitly run the same validation set against multiple objects, etc.

You could also then supply reusable or standard validations - for example, a set of year/month/day properties could be validated using a reusable validation set.

Perhaps a grouping of validations could itself be just another validator - you could call this a "compound validator", "state validator" or "validator set".

View Postkernel, on 27 August 2011 - 07:05 AM, said:

Rules should be more context sensitive.


I think adding more built-in context support increases learning curve, and you can continue extending those sort of features indefinitely and never be quite done.

I think if "compound validators" were classes, you could easily override it's validate() method and introduce any kind of context-sensitivity you like, as code, with much greater flexibility than more "automatic" context sensitivity. I think you could probably even eliminate the notion of "scenario" from models, and have that feature in the "compound validators" instead - you're not really configuring the model object, you're configuring the validation process. Perhaps this is another indication that separation of the validation process would be a cleaner approach.
0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users