Part on Validator Class finished and Part 2 finished

This commit is contained in:
Patryk Hegenberg 2022-12-20 21:23:29 +01:00
parent ef90228439
commit 20aee0812f
2 changed files with 17 additions and 5 deletions

View file

@ -1,4 +1,5 @@
<?php
require('Validator.php');
$heading = 'Create Note';
$username = 'appUser';
$password = 'password';
@ -8,11 +9,8 @@ $db = new Database($config['database'], $username, $password);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$errors = [];
if (strlen($_POST['body'] === 0)) {
$errors['body'] = 'A body is required.';
}
if (strlen($_POST['body'] > 1000)) {
$errors['body'] = 'The body cann not be more than 1000 characters.';
if (! Validator::string($_POST['body'], 1, 1000)) {
$errors['body'] = 'A body of no more than 1000 characters is required.';
}
if (empty($errors)) {