-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
44 lines (32 loc) · 1.03 KB
/
example.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
<?php
require_once('./vendor/autoload.php');
use Rizwan3D\ValidationMyPhp\Validation;
Validation::$DB_HOST = '127.0.0.1';
Validation::$DB_NAME = 'database';
Validation::$DB_PASSWORD = '';
Validation::$DB_USER = 'root';
$validation = new Validation();
$data = [
'firstname' => '',
'username' => '33158413',
'address' => 'This is my address',
'zipcode' => '1',
'email' => 'jo@',
'password' => 'test123',
'password2' => 'test',
];
$fields = [
'firstname' => 'required | max:255',
'lastname' => 'required, max: 255',
'address' => 'required | min: 10, max:255',
'zipcode' => 'between: 5,6',
'username' => 'required | alphanumeric | between: 3,255 | unique: users,username',
'email' => 'required | email | unique: users,email',
'password' => 'required | secure',
'password2' => 'required | same:password'
];
$errors = $validation->validate($data, $fields, [
'required' => 'The %s is required',
'password2' => ['same'=> 'Please enter the same password again']]
);
print_r($errors);