예제 #1
0
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = [$this->getAttribute(), 'string', 'min' => strlen($this->min) ? (int) $this->min : null, 'max' => strlen($this->max) ? (int) $this->max : null, 'length' => strlen($this->length) ? (int) $this->length : null];
     if (isset($this->required)) {
         $rules[] = [$this->getAttribute(), 'required'];
     }
     if (isset($this->pattern)) {
         $rules[] = [$this->getAttribute(), 'match', 'pattern' => $this->pattern];
     }
     if (isset($this->email)) {
         $rules[] = [$this->getAttribute(), 'email'];
     }
     return $rules;
 }