-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
48 lines (39 loc) · 1.45 KB
/
index.php
File metadata and controls
48 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// +------------------------------------------------------------------------+
// | @author : Michael Arawole (Logad Networks)
// | @author_url : https://www.logad.net
// | @author_email : logadscripts@gmail.com
// | @date : 21 Apr, 2023 8:58 AM
// +------------------------------------------------------------------------+
use LogadApp\Validator\Validation;
require 'vendor/autoload.php';
$validator = new Validation;
$rules = [
'test' => 'required|numeric|max:10|min:5',
'text' => 'required|maxLength:5|minLength:3',
'email' => 'required|email',
'type' => 'required|in:user,admin',
'name' => 'requiredIf:type,user,admin',
'proPic2' => 'file|requiredIf:type,user,admin|fileSize:0,1MB|fileType:jpg,png,jpeg',
'profilePic' => 'file|requiredIf:type,user,admin|fileSize:10KB,10KB|fileType:jpg,png,jpeg',
'newFile' => 'file:0,1MB,jpg,png'
];
$validator->make($_POST, $_FILES, $rules);
try {
$validator->validate();
echo 'Is valid?', PHP_EOL;
var_dump($validator->isValid());
echo PHP_EOL;
echo 'Get all errors', PHP_EOL;
print_r($validator->getErrors());
echo PHP_EOL;
echo 'Invalid fields', PHP_EOL;
print_r($validator->getInvalidFields());
echo PHP_EOL;
echo 'Error Messages', PHP_EOL;
print_r($validator->getErrorMessages());
echo 'First Error Message', PHP_EOL;
print_r($validator->getFirstErrorMessage());
} catch (Exception $e) {
echo $e->getMessage();
}