-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser.php
More file actions
43 lines (26 loc) · 841 Bytes
/
user.php
File metadata and controls
43 lines (26 loc) · 841 Bytes
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
<?php
use Rakit\Validation\Validator;
$data = $_SERVER["REQUEST_METHOD"] === "POST"
? $_POST
: null;
$rules = [
"first_name" => "required|min:2|max:15",
"last_name" => "required|min:2|max:15",
"email" => "email",
"password" => "required|min:8",
"password_confirmation" => "required|same:password"
];
$errorMessages = [];
$formSubmittedSuccessfully = false;
if ($data) {
$validator = new Validator();
$validation = $validator->make(
inputs: $data, rules: $rules
);
$validation->validate();
if ( $validation->fails() ) {
$errorMessages = $validation->errors()->firstOfAll();
} else {
$formSubmittedSuccessfully = true;
}
}