Skip to content

Commit bb3f913

Browse files
committed
version 1.0.0 prepared
1 parent ba0de12 commit bb3f913

File tree

12 files changed

+65
-740
lines changed

12 files changed

+65
-740
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ yarn-error.log*
77
lerna-debug.log*
88
.pnpm-debug.log*
99

10+
.DS_Store
11+
12+
vendor/
13+
1014
# Diagnostic reports (https://nodejs.org/api/report.html)
1115
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1216

README.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
# validator
1+
# Validator
22

33
Data validation composer package.
44

55
## Installation
66

7+
Install using composer.
8+
9+
```
10+
composer require codesvault/validator
11+
```
12+
713
<br>
814
<br>
915

@@ -14,6 +20,8 @@ $validator = Validator::validate(
1420
[
1521
'username' => 'required|stringOnly',
1622
'full_name' => 'stringWithSpace',
23+
'password' => 'required|min:8',
24+
'email' => 'required|email',
1725
],
1826
);
1927
```
@@ -36,13 +44,38 @@ $validator = Validator::validate(
3644
```
3745

3846
<br>
47+
<br>
48+
49+
## Handling Errors
3950

40-
`validate` method will return an object of `ValidationEngine` class.
51+
If any data is invalid then `error` method will return error messages array. Otherwise it'll return false.
52+
<br>
53+
`getData` method will return validated data array.
4154

4255
```php
43-
if ($validator->error()) {
44-
return $validator->getErrorList();
56+
$error = $validator->error();
57+
if ($error) {
58+
return $error;
4559
}
46-
47-
return $validator->getData();
60+
$validator->getData();
4861
```
62+
63+
<br>
64+
<br>
65+
66+
## Available Rules
67+
68+
| Rule | Description |
69+
| --- | --- |
70+
| required | Check if the field under validation is present in the input data and is not empty. |
71+
| email | Check if the field under validation is valid email address. |
72+
| url | Check if the field under validation is valid url. |
73+
| string | Check if the field under validation is string. |
74+
| stringOnly | Check if the field under validation is only string charecters. |
75+
| stringWithSpace | Check if the field under validation is string with space. |
76+
| stringWithNumber | Check if the field under validation is string with number. |
77+
| StringWithDash | Check if the field under validation is string with dash and underscore. |
78+
| min | Check if the field under validation is greater than or equal to the given value. |
79+
| max | Check if the field under validation is less than or equal to the given value. |
80+
| integer | Check if the field under validation is integer. |
81+
| sameValue | Check if the field under validation is same as the given value. |

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "codesvault/validator",
3-
"description": "data validator package",
4-
"version": "0.0.1",
3+
"description": "Data validator library",
4+
"version": "1.0.0",
55
"type": "library",
66
"license": "MIT",
77
"autoload": {

composer.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/autoload.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)