-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
59 lines (46 loc) · 1.17 KB
/
test.php
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
49
50
51
52
53
54
55
56
57
58
<?php
require "vendor/autoload.php";
use IconicCodes\LightValidator\LValidator;
$_POST['username'] = 'test';
$_POST['email'] = 'tes';
$_GET['id'] = 10;
$valid_ids = [1,3,4];
$rules = [
'username' => [
'required',
'alphanumeric',
'min' => 3,
'max' => 10
],
'email' => [
'required',
'email'
],
'id' => [
'required',
'numeric',
'in' => $valid_ids
]
];
$overrride_messages = [
'id' => [
'in' => ['ID Must have value betweeen ' . implode(', ', $valid_ids)]
],
'username' => [
'required' => 'Username is required',
'string' => 'Username must be string',
'min' => 'Username must be at least 3 characters',
'max' => 'Username must be at most 10 characters',
],
'email' => [
'required' => 'Email is required',
],
'password' => [
'required' => 'Password is required',
'min' => 'Password must be at least 6 characters',
'max' => 'Password must be at most 10 characters',
],
];
$v = new LValidator($_GET + $_POST, $rules, $overrride_messages);
$results = $v->validate();
var_dump($results);