length($value)) return false; if (!$this->charactor($value)) return false; return true; } /** * Get the validation error message. * * @return string */ public function message() { return $this->message; } private function length(string $value) { $len = strlen($value); if (8 <= $len && $len <= 20) { return true; } else { $this->message = "{$this->min}文字以上 {$this->max}以下で設定してください"; return false; } } private function charactor(string $value) { if (preg_match("/^[a-zA-Z0-9@.\-]+$/", $value) === 0) { $this->message = "半角英数字と記号(@.-)のみ設定可能です。"; return false; } return true; } }