summaryrefslogtreecommitdiff
path: root/includes/form/CreateThreadForm.php
blob: 3774f6a94e4be52b5e5ad5f1b02fd4299308083e (plain)
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
43
44
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;
	}
}