-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add the List of Predefined Rules in readme as documentation
- Loading branch information
1 parent
8d153a3
commit de94ea7
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]', | ||
|
@@ -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()) { | ||
|
@@ -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; | ||
|
||
|
@@ -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; | ||
|
||
|
||
// ... | ||
|
||
|