diff options
Diffstat (limited to 'includes/form/CreateThreadForm.php')
-rw-r--r-- | includes/form/CreateThreadForm.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/includes/form/CreateThreadForm.php b/includes/form/CreateThreadForm.php new file mode 100644 index 0000000..3774f6a --- /dev/null +++ b/includes/form/CreateThreadForm.php @@ -0,0 +1,45 @@ +<?php + +include_once './includes/form/Form.php'; + +class CreateThreadForm extends Form +{ + public function validate_post_content($post_content): ?string + { + $result = null; + + if (empty($post_content)) { + $this->report_error("Post content cannot be empty"); + } else { + $result = filter_var($post_content, FILTER_SANITIZE_STRING); + } + + return $result; + } + + public function validate_thread_subject($thread_subject): ?string + { + $result = null; + + if (empty($thread_subject)) { + $this->report_error("Thread subject cannot be empty"); + } else { + $result = filter_var($thread_subject, FILTER_SANITIZE_STRING); + } + + return $result; + } + + public function validate_thread_category($thread_category): ?int + { + $result = null; + + if (empty($thread_category)) { + $this->report_error("Invalid thread category"); + } else { + $result = filter_var($thread_category, FILTER_SANITIZE_NUMBER_INT); + } + + return $result; + } +}
\ No newline at end of file |