Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CBooleanValidator
  • CCaptchaValidator
  • CCompareValidator
  • CDateValidator
  • CDefaultValueValidator
  • CEmailValidator
  • CExistValidator
  • CFileValidator
  • CFilterValidator
  • CInlineValidator
  • CNumberValidator
  • CRangeValidator
  • CRegularExpressionValidator
  • CRequiredValidator
  • CSafeValidator
  • CStringValidator
  • CTypeValidator
  • CUniqueValidator
  • CUnsafeValidator
  • CUrlValidator
  • CValidator
  • X2UrlValidator
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * CFilterValidator class file.
 4:  *
 5:  * @author Qiang Xue <qiang.xue@gmail.com>
 6:  * @link http://www.yiiframework.com/
 7:  * @copyright 2008-2013 Yii Software LLC
 8:  * @license http://www.yiiframework.com/license/
 9:  */
10: 
11: /**
12:  * CFilterValidator transforms the data being validated based on a filter.
13:  *
14:  * CFilterValidator is actually not a validator but a data processor.
15:  * It invokes the specified filter method to process the attribute value
16:  * and save the processed value back to the attribute. The filter method
17:  * must follow the following signature:
18:  * <pre>
19:  * function foo($value) {...return $newValue; }
20:  * </pre>
21:  * Many PHP 'built in' functions qualify this signature (e.g. trim).
22:  *
23:  * To specify the filter method, set {@link filter} property to be the function name.
24:  *
25:  * @author Qiang Xue <qiang.xue@gmail.com>
26:  * @package system.validators
27:  * @since 1.0
28:  */
29: class CFilterValidator extends CValidator
30: {
31:     /**
32:      * @var callback the filter method
33:      */
34:     public $filter;
35: 
36:     /**
37:      * Validates the attribute of the object.
38:      * If there is any error, the error message is added to the object.
39:      * @param CModel $object the object being validated
40:      * @param string $attribute the attribute being validated
41:      * @throws CException if given {@link filter} is not callable
42:      */
43:     protected function validateAttribute($object,$attribute)
44:     {
45:         if($this->filter===null || !is_callable($this->filter))
46:             throw new CException(Yii::t('yii','The "filter" property must be specified with a valid callback.'));
47:         $object->$attribute=call_user_func_array($this->filter,array($object->$attribute));
48:     }
49: }
50: 
API documentation generated by ApiGen 2.8.0