You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.2 KiB

14 years ago
<?php
/**
14 years ago
* InlineValidator class file.
14 years ago
*
* @link http://www.yiiframework.com/
14 years ago
* @copyright Copyright &copy; 2008-2012 Yii Software LLC
14 years ago
* @license http://www.yiiframework.com/license/
*/
14 years ago
namespace yii\validators;
14 years ago
/**
14 years ago
* InlineValidator represents a validator which is defined as a method in the object being validated.
*
* The validation method must have the following signature:
*
* ~~~
* function foo($attribute, $params)
* ~~~
*
* where `$attribute` refers to the name of the attribute being validated, while `$params`
* is an array representing the additional parameters supplied in the validation rule.
14 years ago
*
* @author Qiang Xue <qiang.xue@gmail.com>
14 years ago
* @since 2.0
14 years ago
*/
14 years ago
class InlineValidator extends Validator
14 years ago
{
/**
* @var string the name of the validation method defined in the active record class
*/
public $method;
/**
* @var array additional parameters that are passed to the validation method
*/
public $params;
/**
* Validates the attribute of the object.
14 years ago
* @param \yii\base\Model $object the object being validated
14 years ago
* @param string $attribute the attribute being validated
*/
14 years ago
public function validateAttribute($object, $attribute)
14 years ago
{
$method = $this->method;
$object->$method($attribute, $this->params);
}
}