yiisoft/yii — pull request #1374 by suralc (2012-09-10 15:42:15+00:00)
Title: [WIP]Sanitize in model

Work in progress - Do not merge

This pr implements sanitization rules as requested in http://www.yiiframework.com/forum/index.php/topic/29362-cmodelsanitize/

Why this is needed/usefull?
===

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).

Whats included, whats not
===
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.

Only 3 core-sanitizers are included. I will create some more as soon as I know if this is considered