user test input val

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

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

@ -56,6 +56,19 @@ class home_ctrl extends base_controller {
return $this->response; 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() { public function extra() {
$loaded = \CodeHydrater\extras_booter::tryToEnableFeature("testing", refresh: true); $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