yii\validators\RegularExpressionValidator::validateValue PHP Method

validateValue() protected method

protected validateValue ( $value )
    protected function validateValue($value)
    {
        $valid = !is_array($value) && (!$this->not && preg_match($this->pattern, $value) || $this->not && !preg_match($this->pattern, $value));
        return $valid ? null : [$this->message, []];
    }

Usage Example

 protected function internalValidateValue(&$value)
 {
     $result = parent::validateValue($value);
     if (empty($result)) {
         if ($this->allowNamespace) {
             $result = $this->validateNsSeparator($value, 0, $this->leadingNamespaceSeparator);
         } else {
             if (!$this->allowNamespace && !$model->hasErrors()) {
                 if (strpos($model->{$attribute}, '\\') !== FALSE) {
                     $result = ['Namespace may not be specified', null];
                 }
             }
         }
     }
     return $result;
 }