Skip to content

Commit

Permalink
add the List of Predefined Rules in readme as documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
BlakvGhost committed Nov 17, 2023
1 parent 8d153a3 commit de94ea7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ composer require blakvghost/php-validator
```php
use BlakvGhost\PHPValidator\Validator;
use BlakvGhost\PHPValidator\ValidatorException;
use BlakvGhost\PHPValidator\LangManager;
use BlakvGhost\PHPValidator\Rules\EmailRule;

try {

// $validator = new Validator($_POST, [
// 'username' => 'required|string:25',
// 'email' => 'required|email',
// 'score' => ['required','max_length:200', new CustomRule()],
// ]);
// or

$validator = new Validator([
'username' => 'BlakvGhost',
'email' => '[email protected]',
Expand All @@ -31,6 +37,7 @@ try {
'username' => 'required|string:25',
'email' => 'required|email',
'score' => ['required','max_length:200', new CustomRule()],
'password' => new CustomRule(),
]);

if ($validator->isValid()) {
Expand Down Expand Up @@ -173,7 +180,7 @@ In addition to the predefined rules, you can create custom validation rules by i

```php
// CustomPasswordRule.php
namespace BlakvGhost\PHPValidator\Rules;
namespace YourNameSpace\Rules;

use BlakvGhost\PHPValidator\LangManager;

Expand Down Expand Up @@ -204,7 +211,9 @@ class CustomPasswordRule implements RuleInterface
```php

use BlakvGhost\PHPValidator\Validator;
use BlakvGhost\PHPValidator\Rules\CustomPasswordRule;
use BlakvGhost\PHPValidator\ValidatorException;
use YourNameSpace\CustomPasswordRule;


// ...

Expand Down

0 comments on commit de94ea7

Please sign in to comment.