From 839265e852fb637265576b80880f1becf35dc156 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Tue, 21 Jun 2016 00:19:44 -0300 Subject: [PATCH] (Guillermo) Create path /ticket/create --- server/controllers/ticket/create.php | 8 ++++---- server/models/ERRORS.php | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/controllers/ticket/create.php b/server/controllers/ticket/create.php index d192d56b..e9ae2698 100644 --- a/server/controllers/ticket/create.php +++ b/server/controllers/ticket/create.php @@ -31,16 +31,16 @@ class CreateController extends Controller { private function validateData() { if (strlen($this->title) < 3) { - return 'title is too short'; + Response::respondError(ERRORS::SHORT_TITLE); } if (strlen($this->title) > 30) { - return 'title is very long'; + Response::respondError(ERRORS::LONG_TITLE); } if (strlen($this->content) < 5) { - return 'content is too short'; + Response::respondError(ERRORS::SHORT_CONTENT); } if (strlen($this->content) > 500) { - return 'content is very long'; + Response::respondError(ERRORS::LONG_CONTENT); } return true; diff --git a/server/models/ERRORS.php b/server/models/ERRORS.php index 144914e9..76d29f3c 100644 --- a/server/models/ERRORS.php +++ b/server/models/ERRORS.php @@ -2,4 +2,8 @@ class ERRORS { const INVALID_CREDENTIALS = 'User or password is not defined'; const SESSION_EXISTS = 'User is already logged in'; + const SHORT_TITLE = 'Title is too short'; + const LONG_TITLE = 'Title is very long'; + const SHORT_CONTENT = 'Content is too short'; + const LONG_CONTENT = 'Content is very long'; }