Skip to content

Commit

Permalink
Merge pull request BlakvGhost#4 from v1p3r75/v1p3r75/updated-document…
Browse files Browse the repository at this point in the history
…ation

V1p3r75/updated documentation
  • Loading branch information
BlakvGhost committed Nov 17, 2023
2 parents ea2ac67 + 2711a19 commit f468b78
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
62 changes: 60 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ try {
// $data = $_POST;

$validator = new Validator($data, [
'username' => 'required|string:25',
'username' => 'required|string',
'email' => 'required|email',
'score' => ['required','max_length:200', new CustomRule()],
'password' => new CustomRule(),
Expand Down Expand Up @@ -185,8 +185,66 @@ PHPValidator provides a variety of predefined rules that you can use for data va

```php
'username' => 'min_length:8'

```
19. **Not In Rule**
- Validates that a field's value is not in a specified set.

```php
'value' => 'not_in:["foo", "bar"]'
```
20. **Required With Rule**
- Requires the field to be present if another specified field is present.


```php
'firstname' => 'required_with:lastname',
```

21. **Valid IP Rule**
- Validates that a field's value is a valid IP address.

```php
'client_ip' => 'valid_ip',
```

22. **Json Rule**
- Validates that a field's value is a valid JSON string.

```php
'config' => 'json',
```

23. **URL Rule**
- Validates that a field's value is a valid URL.

```php
'website' => 'url',
```
24. **Alpha Numeric Rule**
- Validates that a field's value contains only alphanumeric characters.

```php
'pseudo' => 'alpha_numeric',
```

25. **Boolean Rule**
- Validates that a field's value is a boolean.

```php
'is_admin' => 'boolean',
```

26. **Size Rule**
- Validates that the size of a string, integer, array, or file is equal to a specified value.

```php
[
'string' =>'size:7', // strlen(string) == 7
'integer' =>'size:7', // integer == 7
'array' =>'size:7', // count(array) == 7
'file' =>'size:512', // file size (kb) == 512
]
```
## Custom Rule

In addition to the predefined rules, you can create custom validation rules by implementing the `RuleInterface`. Here's an example of how to create and use a custom rule:
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/RuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use BlakvGhost\PHPValidator\Rules\AcceptedIfRule;
use BlakvGhost\PHPValidator\Rules\AcceptedRule;
use BlakvGhost\PHPValidator\Rules\ActiveURLRule;
use BlakvGhost\PHPValidator\Rules\AlphaNumeric;
use BlakvGhost\PHPValidator\Rules\AlphaNumericRule;
use BlakvGhost\PHPValidator\Rules\AlphaRule;
use BlakvGhost\PHPValidator\Rules\BooleanRule;
Expand Down

0 comments on commit f468b78

Please sign in to comment.