Yii Framework Forum: Separated validation and transformation rules - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Separated validation and transformation rules

#1 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 664
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 23 February 2012 - 09:38 AM

Maybe it is a good idea to separate the data validation rules from the data transformation rules.
For example, CDefaultValueValidator and CFilterValidator are not validators.

This may cause a problem with the order of execution, though.
Please comment.
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,350
  • Joined: 17-January 09
  • Location:Russia

Posted 23 February 2012 - 10:23 AM

What's the practical purpose? Just for clarity?
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#3 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 664
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 23 February 2012 - 12:14 PM

Clarity would be a good additional benefit, but it is not the main purpose.

This change would be useful in cases you don't want to run the (real) validation, but you still depend on some transformations to get the information from a temporary atribute and format to a definitive attribute and format for later model use or AR storage.
Having a scenario, a setter or a custom onBeforeSave event handler could be an easy fix for this, though.
2

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,350
  • Joined: 17-January 09
  • Location:Russia

Posted 24 February 2012 - 09:06 PM

Yeah. My first thought was describe rules for "filter" scenario and then validate just this scenario.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

Share this topic:


Page 1 of 1
  • 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