Browse Source

validator wip

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
62fd92bf72
  1. 9
      framework/validators/BooleanValidator.php
  2. 8
      framework/validators/Validator.php

9
framework/validators/BooleanValidator.php

@ -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
framework/validators/Validator.php

@ -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.
*

Loading…
Cancel
Save