eee
This commit is contained in:
+3
-3
@@ -71,7 +71,7 @@ abstract class BaseValidator
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
* @throws
|
||||
*/
|
||||
public function trigger(): bool
|
||||
{
|
||||
@@ -109,7 +109,7 @@ abstract class BaseValidator
|
||||
$message = str_replace(':attribute', $field, $message);
|
||||
}
|
||||
|
||||
\trigger_print_error($message,"mysql");
|
||||
\trigger_print_error($message, "mysql");
|
||||
$this->message = $message;
|
||||
|
||||
return $this->isFail;
|
||||
@@ -147,7 +147,7 @@ abstract class BaseValidator
|
||||
/**
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @throws Exception
|
||||
* @throws
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
|
||||
@@ -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
@@ -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
@@ -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;
|
||||
|
||||
|
||||
+2
-2
@@ -19,14 +19,14 @@ class RoundValidator extends BaseValidator
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
* @throws
|
||||
*/
|
||||
public function trigger(): bool
|
||||
{
|
||||
return $this->_validator($this->field, function ($field, $model, $param) {
|
||||
$value = $model->getAttribute($field);
|
||||
if ($value == null || round($value, $param) != $value) {
|
||||
return $this->addError($field,'The param :attribute length error');
|
||||
return $this->addError($field, 'The param :attribute length error');
|
||||
}
|
||||
return true;
|
||||
}, $this->model, $this->value);
|
||||
|
||||
@@ -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
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user