Skip to content

Commit 8b30204

Browse files
author
kek91
committed
Usage example in readme.md
1 parent 4029a74 commit 8b30204

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
Easy to use PHP class for validating user input from HTML form input fields or anywhere else you may use it.
55

6-
Please note this is only `validation`, for very critical operations you may need to consider `sanitizing` before submitting user data to DB etc. I assume you're already well aware of the dangers.
6+
Please note this is only `validation`, for critical operations you may need to consider `sanitizing` before submitting user data to DB etc. I assume you're already well aware of the dangers.
77

88
### Features
99

@@ -12,14 +12,40 @@ Please note this is only `validation`, for very critical operations you may need
1212
- Custom error messages for each input field
1313
- Lightweight and fast
1414
- Validate different types of input:
15-
- Telephone number
16-
- Email address
17-
- Name
18-
- Text
15+
- Verify valid email address
16+
- Alphabetic only
17+
- Numeric only
1918
- ++
2019

21-
### Usage examples
20+
### Usage example
2221

22+
**HTML form**
2323
```
24-
...
24+
<form>
25+
<input type="text" name="email">
26+
<input type="submit">
27+
</form>
28+
```
29+
**PHP processing**
30+
```
31+
$validate = new Validate();
32+
$validation = $validate->check($_POST, array(
33+
'email' => array(
34+
'required' => true,
35+
'mailcheck' => true
36+
)
37+
));
38+
39+
if($validation->passed()) {
40+
echo 'Validation passed!';
41+
}
42+
else {
43+
echo 'Validation errors:';
44+
echo '<ul>';
45+
foreach($validation->errors() as $error)
46+
{
47+
echo '<li>'.ucfirst($error).'</li>';
48+
}
49+
echo '</ul>';
50+
}
2551
```

0 commit comments

Comments
 (0)