Commit 62fd92bf by Qiang Xue

validator wip

parent 0e8e94bc
......@@ -60,6 +60,15 @@ class BooleanValidator extends Validator
}
}
public function validateValue($value)
{
if ($this->allowEmpty && $this->isEmpty($value)) {
return;
}
return ($this->strict || $value == $this->trueValue || $value == $this->falseValue)
&& (!$this->strict || $value === $this->trueValue || $value === $this->falseValue);
}
/**
* Returns the JavaScript needed for performing client-side validation.
* @param \yii\base\Model $object the data object being validated
......
......@@ -8,6 +8,7 @@
namespace yii\validators;
use yii\base\Component;
use yii\base\NotSupportedException;
/**
* Validator is the base class for all validators.
......@@ -81,7 +82,7 @@ abstract class Validator extends Component
*/
public $message;
/**
* @var array list of scenarios that the validator should be applied.
* @var array list of scenarios that the validator can be applied to.
*/
public $on = array();
/**
......@@ -174,6 +175,11 @@ abstract class Validator extends Component
}
}
public function validateValue($value)
{
throw new NotSupportedException(__CLASS__ . ' does not support validateValue().');
}
/**
* Returns the JavaScript needed for performing client-side validation.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment