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 de94ea7 commit 8ed0541
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@ use BlakvGhost\PHPValidator\ValidatorException;

try {

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

$validator = new Validator([
$data = [
'username' => 'BlakvGhost',
'email' => '[email protected]',
'score' => 42,
], [
];
// or
// $data = $_POST;

$validator = new Validator($data, [
'username' => 'required|string:25',
'email' => 'required|email',
'score' => ['required','max_length:200', new CustomRule()],
Expand Down Expand Up @@ -218,10 +215,15 @@ use YourNameSpace\CustomPasswordRule;
// ...

try {
$validator = new Validator([

$data = [
'password' => '42',
'confirm_password' => '142',
], [
];
// or
// $data = $_POST;

$validator = new Validator($data, [
'password' => ['required', new CustomPasswordRule()],
]);

Expand Down

0 comments on commit 8ed0541

Please sign in to comment.