This commit is contained in:
2023-12-12 15:35:34 +08:00
parent 26030fd148
commit d860269a7c
7 changed files with 217 additions and 218 deletions
+2 -2
View File
@@ -71,7 +71,7 @@ abstract class BaseValidator
/**
* @return bool
* @throws Exception
* @throws
*/
public function trigger(): bool
{
@@ -147,7 +147,7 @@ abstract class BaseValidator
/**
* @param $name
* @param $value
* @throws Exception
* @throws
*/
public function __set($name, $value)
{
+4 -4
View File
@@ -13,10 +13,10 @@ namespace validator;
class DateTimeValidator extends BaseValidator
{
const DATE = 'date';
const DATE_TIME = 'datetime';
const TIME = 'time';
const STR_TO_TIME = 'timestamp';
const string DATE = 'date';
const string DATE_TIME = 'datetime';
const string TIME = 'time';
const string STR_TO_TIME = 'timestamp';
public string $method;
+2 -2
View File
@@ -19,10 +19,10 @@ class EmptyValidator extends BaseValidator
{
/** @var string [不能为空] */
const CAN_NOT_EMPTY = 'not empty';
const string CAN_NOT_EMPTY = 'not empty';
/** @var string [可为空, 不能为null] */
const CAN_NOT_NULL = 'not null';
const string CAN_NOT_NULL = 'not null';
public string $method;
+2 -2
View File
@@ -13,8 +13,8 @@ namespace validator;
class LengthValidator extends BaseValidator
{
const MAX_LENGTH = 'max';
const MIN_LENGTH = 'min';
const string MAX_LENGTH = 'max';
const string MIN_LENGTH = 'min';
public string $method;
+1 -1
View File
@@ -19,7 +19,7 @@ class RoundValidator extends BaseValidator
/**
* @return bool
* @throws Exception
* @throws
*/
public function trigger(): bool
{
+5 -5
View File
@@ -14,11 +14,11 @@ class TypesOfValidator extends BaseValidator
{
const JSON = 'json';
const FLOAT = 'float';
const ARRAY = 'array';
const STRING = 'string';
const INTEGER = 'integer';
const string JSON = 'json';
const string FLOAT = 'float';
const string ARRAY = 'array';
const string STRING = 'string';
const string INTEGER = 'integer';
private ?int $min = null;
private ?int $max = null;
+4 -5
View File
@@ -7,7 +7,6 @@ namespace validator;
use Closure;
use Database\ModelInterface;
use Exception;
use Kiri;
/**
@@ -40,7 +39,7 @@ class Validator extends BaseValidator
* @param $field
* @param $rules
* @return $this
* @throws Exception
* @throws
*/
public function make($field, $rules): static
{
@@ -61,7 +60,7 @@ class Validator extends BaseValidator
* @param $rule
* @param $model
* @param $param
* @throws Exception
* @throws
* ['maxLength'=>150, 'required', 'minLength' => 100]
*/
public function createRule($field, $rule, $model, $param): void
@@ -88,7 +87,7 @@ class Validator extends BaseValidator
/**
* @return bool
* @throws Exception
* @throws
*/
public function validation(): bool
{
@@ -113,7 +112,7 @@ class Validator extends BaseValidator
/**
* @param BaseValidator|array|Closure $val
* @return array
* @throws Exception
* @throws
*/
private function check(BaseValidator|array|Closure $val): array
{