user test input val

main
Robert 2 months ago
parent 3ee14b32c8
commit 1b92c77116
  1. 1
      protected/cli/run.php
  2. 15
      protected/src/controllers/app/home_ctrl.php
  3. 29
      protected/src/inputs/test_val.php

@ -1,3 +1,4 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);

@ -22,7 +22,7 @@ class home_ctrl extends base_controller {
// Defined from: on_footer_banner.php in the configs folder...
$this->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);

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
/**
* @author Robert Strutts <Bob_586@Yahoo.com>
* @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;
}
}
Loading…
Cancel
Save