diff options
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | src/Hird.php | 2 |
2 files changed, 4 insertions, 2 deletions
@@ -42,10 +42,12 @@ if ($hird->fails()) { } ``` -From the above example, you can see that there are two Hird methods being used such as `$hird->fails()` and `$hird->errors()`. The `$hird->fails()` method will return a boolean depending on whether the validation failed or not, `true` if it did. The `$hird->errors()` method will return an array of all the errors that occured, as defined by the validators. +From the above example, you can see that there are two Hird methods being used such as `$hird->fails()` and `$hird->errors()`. The `$hird->fails()` method will run the validation and return a boolean depending on whether the validation failed or not, `true` if it did. The `$hird->errors()` method will return an array of all the errors that occured, as defined by the validators. You can also get the first error rather than all errors by using the method `$hird->firstError()`. +If you wish to run the validation without needing to call `$hird->fails()`, you can instead call `$hird->validate()`. + ## Built-in validators There are a number of built-in validators available for use by default. If you want to remove a built-in validator, you can remove one using the `$hird->removeValidator('rule-name')` method. diff --git a/src/Hird.php b/src/Hird.php index d33a9ae..5ff3b31 100644 --- a/src/Hird.php +++ b/src/Hird.php @@ -96,7 +96,7 @@ class Hird * * @return void */ - private function validate(): void + public function validate(): void { foreach ($this->rules as $field => $rule) { $value = isset($this->fields[$field]) ? $this->fields[$field] : ''; |
