From 1b92c77116c6eef4876d0527f4ba1c21ac5bccbe Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 13 Dec 2025 16:45:46 -0500 Subject: [PATCH] user test input val --- protected/cli/run.php | 1 + protected/src/controllers/app/home_ctrl.php | 15 ++++++++++- protected/src/inputs/test_val.php | 29 +++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) mode change 100644 => 100755 protected/cli/run.php create mode 100644 protected/src/inputs/test_val.php diff --git a/protected/cli/run.php b/protected/cli/run.php old mode 100644 new mode 100755 index 29700d0..634feef --- a/protected/cli/run.php +++ b/protected/cli/run.php @@ -1,3 +1,4 @@ +#!/usr/bin/env php set_footer_and_authors(); } - + public function index() { $this->view->set('html', $this->html); $this->view->set_template('main'); @@ -55,6 +55,19 @@ class home_ctrl extends base_controller { $this->response->set_content($content); return $this->response; } + + public function val_tests() { + $user_test = new \Project\inputs\test_val("Joe", 10, "Joe@AOL.com"); + + $v = new \CodeHydrater\attributes\validators\my_validator(); + $v->validate($user_test); + + $errors = $v->get_errors(); + print_r($errors); + + $this->response->set_content("Done"); + return $this->response; + } public function extra() { $loaded = \CodeHydrater\extras_booter::tryToEnableFeature("testing", refresh: true); diff --git a/protected/src/inputs/test_val.php b/protected/src/inputs/test_val.php new file mode 100644 index 0000000..8f4351c --- /dev/null +++ b/protected/src/inputs/test_val.php @@ -0,0 +1,29 @@ + + * @copyright (c) 2025, Robert Strutts + * @license MIT + */ + +namespace Project\inputs; + +use \CodeHydrater\attributes\validators as Assert; + +class test_val { + public function __construct( + #[Assert\Required] + #[Assert\Max(70)] + public ?string $name = null, + #[Assert\Positive] + #[Assert\NumberRange(18, 65)] + public ?int $age = null, + #[Assert\Between(2, 255)] + #[Assert\Email] + public ?string $email = null + ) { + echo $this->name; + } +} \ No newline at end of file