diff --git a/Validator.php b/Validator.php new file mode 100644 index 0000000..11f590e --- /dev/null +++ b/Validator.php @@ -0,0 +1,14 @@ += $min && strlen($value) <= $max; + } + public static function email($value) + { + return filter_var($value, FILTER_VALIDATE_EMAIL); + } +} \ No newline at end of file diff --git a/controllers/note-create.php b/controllers/note-create.php index 7691083..1902de7 100644 --- a/controllers/note-create.php +++ b/controllers/note-create.php @@ -1,4 +1,5 @@ 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)) {