Skip to content

Commit

Permalink
Merge pull request #27 from kris-kuiper/documentation
Browse files Browse the repository at this point in the history
Updated documentation
  • Loading branch information
kris-kuiper committed Sep 7, 2022
2 parents 670abb4 + 3bf3007 commit 768087e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
31 changes: 14 additions & 17 deletions README.md
Expand Up @@ -70,26 +70,22 @@ Modern PHP Validator provides several approaches to validate your application's

```php
$data = [
'programmers' => [
'department' => 'office',
'color' => 'black',
'programmer' => [
'name' => 'Morris',
'email' => 'morris@domain.com'
],
'developers' => [
'name' => 'Smith',
'email' => 'smith@domain.com'
],
'department' => 'office',
'color' => 'black'
];

$validator = new Validator($data);

//Select every email field within an array using wildcards and attach rules
$validator->field('*.email')->required()->email()->lengthMax(50);

//Select department and color field and attach rules
$validator->field('department', 'color')->required(false)->isString()->lengthBetween(5, 20);

//Select email field within the programmer array and attach rules
$validator->field('programmer.email')->required()->email()->lengthMax(50);

if($validator->passes()) {
//Validation passes
}
Expand All @@ -103,18 +99,19 @@ And this is just the beginning...

Modern PHP Validator is available on Packagist (using semantic versioning). Installation via [Composer](https://getcomposer.org/) is the recommended way.

Just add this line to your composer.json file:
Run:
```shell script
"kris-kuiper/validator": "^1.1"
composer require kris-kuiper/validator
```

or run:
Or add this line to your composer.json file:
```shell script
composer require kris-kuiper/validator
"kris-kuiper/validator": "^1.2"
```




# Let's begin

First things first: <u>rules are executed in the order they are defined</u>.
Expand Down Expand Up @@ -862,7 +859,7 @@ $valdiator->field('fieldName')->ip();



##### IP private
##### IP private

Checks if the data under validation is a private IP address (v4 or v6).

Expand All @@ -872,7 +869,7 @@ $valdiator->field('fieldName')->ipPrivate();



##### IP public
##### IP public

Checks if the data under validation is a public ip address (v4 or v6).

Expand Down Expand Up @@ -1722,7 +1719,7 @@ $error = $validator->errors()->first();
$error = $validator->errors('username')->first();
```

We now have a single error object stored in the `$error` variable.
We now have a single error object stored in the `$error` variable.

This object has several handy methods:

Expand Down
2 changes: 1 addition & 1 deletion composer.json
@@ -1,7 +1,7 @@
{
"name": "kris-kuiper/validator",
"type": "library",
"description": "Modern PHP validator for validating forms and/or array's on steroids.",
"description": "Modern PHP validator on steroids for validating forms and/or array's.",
"keywords": [
"modern",
"validate",
Expand Down

0 comments on commit 768087e

Please sign in to comment.