diff --git a/classen/FormValidator.php b/classen/FormValidator.php new file mode 100644 index 0000000..097bd37 --- /dev/null +++ b/classen/FormValidator.php @@ -0,0 +1,25 @@ +fieldValidation = $fieldValidation; + } + + public function isValid(array $req) { + foreach($fieldValidation as $field => $params) { + if($params['required'] && !isset($req[$field])) { + return false; + } + + if(isset($params['regex']) && !preg_match($params['regex'], $req[$field])) { + return false; + } + } + + return true; + } + +} +?> \ No newline at end of file