-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
42 lines (34 loc) · 1.04 KB
/
index.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
<?php
require_once dirname(__FILE__, 3) . '/vendor/autoload.php';
use Assert\Assertion;
use Assert\AssertionFailedException;
try {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$userData = [
'name' => $_POST['name'],
'email' => $_POST['email'],
'password' => $_POST['password'],
'img' => $_FILES['img'],
'active' => NULL,
];
if (isset($_POST['active'])) {
$userData['active'] = $_POST['active'];
}
echo "<ul>";
foreach ($userData as $key => $value) {
if (Assertion::notNull($key)) {
echo "<li>The {$key} should NOT be NULL</li>";
}
}
echo "</ul>";
Assertion::betweenLength(
$userData['password'],
10,
20,
'The password should be between 10 and 20 characters'
);
Assertion::file($userData['img'], 'The picture should be correct file');
}
} catch (AssertionFailedException $e) {
echo $e->getMessage();
}