From a5ba22b56241c8fd044d9d15a1158ad677c8ffc4 Mon Sep 17 00:00:00 2001 From: Jaroslaw Rozanski Date: Wed, 29 Dec 2021 02:09:28 +0100 Subject: [PATCH] Validate User Input and report input errors --- types/WideAngleValidated.php | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 types/WideAngleValidated.php diff --git a/types/WideAngleValidated.php b/types/WideAngleValidated.php new file mode 100644 index 0000000..80f7487 --- /dev/null +++ b/types/WideAngleValidated.php @@ -0,0 +1,49 @@ +name = $name; + $this->value = $value; + $this->normalized = $normalized; + $this->error = $error; + $this->isValid = $isValid; + } + + public static function createValid($name, $value, $normalized) { + return new self($name, $value, $normalized, null, true); + } + + public static function createInvalid($name, $value, $error) { + return new self($name, $value, null, $error, false); + } + + public function get_name() { + return $this->name; + } + + public function get_value() { + if($this->normalized !== null) { + return $this->normalized; + } + return $this->value; + } + + public function get_error() { + if(!$this->isValid) { + return $this->error; + } + return null; + } + + public function is_valid() { + return $this->isValid; + } + +} +?> \ No newline at end of file