public function addRule($validator, $message = NULL, $arg = NULL)
{
if ($this->control->type === NULL && in_array($validator, [Form::EMAIL, Form::URL, Form::INTEGER], TRUE)) {
static $types = [Form::EMAIL => 'email', Form::URL => 'url', Form::INTEGER => 'number'];
$this->control->type = $types[$validator];
} elseif (in_array($validator, [Form::MIN, Form::MAX, Form::RANGE], TRUE) && in_array($this->control->type, ['number', 'range', 'datetime-local', 'datetime', 'date', 'month', 'week', 'time'], TRUE)) {
if ($validator === Form::MIN) {
$range = [$arg, NULL];
} elseif ($validator === Form::MAX) {
$range = [NULL, $arg];
} else {
$range = $arg;
}
if (isset($range[0]) && is_scalar($range[0])) {
$this->control->min = isset($this->control->min) ? max($this->control->min, $range[0]) : $range[0];
}
if (isset($range[1]) && is_scalar($range[1])) {
$this->control->max = isset($this->control->max) ? min($this->control->max, $range[1]) : $range[1];
}
} elseif ($validator === Form::PATTERN && is_scalar($arg) && in_array($this->control->type, [NULL, 'text', 'search', 'tel', 'url', 'email', 'password'], TRUE)) {
$this->control->pattern = $arg;
}
return parent::addRule($validator, $message, $arg);
}