diff options
| author | Asko Nomm <asko@bien.ee> | 2022-02-22 23:42:19 +0100 |
|---|---|---|
| committer | Asko Nomm <asko@bien.ee> | 2022-02-22 23:42:19 +0100 |
| commit | 037f2f0dba509bbfbd96efb8810e6a2e13295c3d (patch) | |
| tree | 3273b76755c099e186f8625294b73a52852078de | |
| parent | fba4870096757e0274441f4ac35ec01831ab61da (diff) | |
Add namespaces to README
| -rw-r--r-- | README.md | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -31,6 +31,8 @@ For example, say we have a validator called `len` which takes a modifier that le An example usage of Bouncer looks like this: ```php +use Askonomm\Bouncer\Bouncer; + $fields = ['email' => 'asko@bien.ee']; $rules = ['email' => 'required|email|len:5']; $bouncer = new Bouncer($fields, $rules); @@ -53,6 +55,8 @@ There are a number of built-in validators avaiable for use by default. If you wa The `email` validator validates an e-mail address, and it is registered as the `email` rule. ```php +use Askonomm\Bouncer\Bouncer; + $fields = ['email' => 'asko@bien.ee']; $rules = ['email' => 'email']; $bouncer = new Bouncer($fields, $rules); @@ -63,6 +67,8 @@ $bouncer = new Bouncer($fields, $rules); The `len` validator validates the length of a string, and it is registered as the `len` rule. The `len` validator also accepts, and requires, a modifier. A modifier can be passed to a rule by appending a color character `:` to it, and passing the modifier after it, like `len:8`. ```php +use Askonomm\Bouncer\Bouncer; + $fields = ['password' => 'SuperSecretPassword']; $rules = ['password' => 'len:10']; $bouncer = new Bouncer($fields, $rules); @@ -73,6 +79,8 @@ $bouncer = new Bouncer($fields, $rules); The `required` validator validates the presence of value, and it is registered as the `required` rule. It will pass validation if the value is set and the value is not an empty string. ```php +use Askonomm\Bouncer\Bouncer; + $fields = ['password' => 'SuperSecretPassword']; $rules = ['password' => 'required']; $bouncer = new Bouncer($fields, $rules); @@ -88,6 +96,8 @@ You can also create your own validators, or replace existing ones if you're not A validator is a class that implements the `Validator` interface. A full example of a correct validator would look something like this: ```php +use Askonomm\Bouncer\Validators\Validator; + class EmailValidator implements Validator { /** |
