Work in progress - Do not merge
This pr implements sanitization rules as requested in http://www.yiiframework.com/forum/index.php/topic/29362-cmodelsanitize/
Validators can be used to achive the same goal. But there is a difference in concept. Validators should just validate data not change(sanitize) it. If I validate user input I should just receive a feedback if it is valid or not. A validator should not affect data it validates.
Sanitization can be used to clean user data, make sure a number is non-negative or whatever is wanted. If we use a sanitizer we expect the data to be changed, regardless if it is valid(or sanitize it before validating).
Implementation follows validators. There is some code duplication which can't be avoided without moving functionality from valdators to more abstract methods (or creating some useless aliases).
Some unit-tests are included, I will rework them, as soon as I know this is considered.
Documentation is todo. (See tests for examples)
Only 3 core-sanitizers are included. I will create some more as soon as I know if this is considered
Added support for sanitizers.
- unit tests
- guide entries
- spaces to tabs
Converted spaces to tabs
Added some tests.
Improved some tests.
Configuration should be public.
Refactored sanatizors to sanitizors.
Sanitization rule in gii-generator.
Merge remote-tracking branch 'remotes/upstream/master' into sanatizeI…
Documentation changes and small test improvement.
This is not Yii way. Absolutely wrong approach.
For example you can do same things:
public function rules()
What you try to do with this PR? Change brilliant Yii approach? Thanks, i pass. Sure 90% of community pass too.
P.S. Try to perceive that Yii «validators» is «validators or/and sanitizators». For example file validator is validator + sanitizator.
I know the same can be achieved using validatory. But thats not the point.
This is about to have a 'clean' way to seperate data changing methods from pure readers. Also sanitizing data has not much todo with validating as it is contextfree and is used without relying on the current state of the model( real validators have to in the most cases)
I could also create a special scenario to seperate validators from, sanitizors but I doubt that this is the way to go.
Send via github for android. Sorry for not formatting the comment
@suralc What if the validator at the same time should check and change?
I don't think we'll accept it: