<?php

	use vlw\MySQL\Operators;
	use Reflect\{Response, Path};
	use Reflect\Rules\{Ruleset, Rules, Type};

	use VLW\Database\Database;
	use VLW\Database\Tables\Search\SearchTable;

	require_once Path::root("src/Database/Database.php");
	require_once Path::root("src/Database/Tables/Search/Search.php");

	class DELETE_Search extends Database {
		protected Ruleset $ruleset;

		public function __construct() {
			$this->ruleset = new Ruleset(strict: true);

			$this->ruleset->POST([
				(new Rules(SearchTable::ID->value))
					->required()
					->type(Type::STRING)
					->min(2)
					->max(parent::SIZE_VARCHAR)
			]);

			$this->ruleset->validate_or_exit();

			parent::__construct();
		}

		public function main(): Response {
			return $this->db->for(SearchTable::NAME)->delete($_POST) === true ? new Response() : new Response("", 500);
		}
	}