/** * @return bool */ public function isValid() { if ($this->data === null || empty($this->data)) { $this->setErrorMessage($this->attributes["validatorName"], Lang::get("validator.required", ['name' => $this->attributes["name"]], "The {name} field is required.")); return false; } return true; }
/** * @return bool */ public function isValid() { if ($this->data !== null && !preg_match("/" . $this->attributes['arg'] . "/", $this->data)) { $this->setErrorMessage($this->attributes["validatorName"], Lang::get("validator.regex", ['format' => $this->attributes['arg'], 'name' => $this->attributes["name"], 'value' => $this->data], "{name} ({value}) is not in the expected format {format}.")); return false; } return true; }