dbmsv4/app/Forms/Auth/LocalForm.php
2025-11-18 16:54:55 +09:00

31 lines
746 B
PHP

<?php
namespace App\Forms\Auth;
use App\Forms\CommonForm;
class LocalForm extends CommonForm
{
public function __construct()
{
parent::__construct();
}
public function getFormRule(string $action, string $field): string
{
switch ($field) {
case "id":
$rule = "required|trim|min_length[4]|max_length[20]";
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "";
break;
case "passwd":
$rule = in_array($action, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
break;
default:
$rule = parent::getFormRule($action, $field);
break;
}
return $rule;
}
}