"required|regex:/#[0-9A-Fa-f]{6}\b/", ]; if($this->isMethod("patch")) { $rules["name"] = "required|min:2|unique:categories,id," . $this->route("id"); } else { $rules["name"] = "required|min:2|unique:categories"; } return $rules; } }