改名
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/4/3 0003
|
||||
* Time: 15:28
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
@@ -12,7 +13,7 @@ abstract class BaseValidator
|
||||
|
||||
public $rules;
|
||||
|
||||
public $method;
|
||||
public string $method;
|
||||
|
||||
protected $isFail = TRUE;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/4/3 0003
|
||||
* Time: 15:42
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
@@ -35,16 +36,12 @@ class DateTimeValidator extends BaseValidator
|
||||
switch (strtolower($this->method)) {
|
||||
case self::DATE:
|
||||
return $this->validatorDate($value);
|
||||
break;
|
||||
case self::DATE_TIME:
|
||||
return $this->validateDatetime($value);
|
||||
break;
|
||||
case self::TIME:
|
||||
return $this->validatorTime($value);
|
||||
break;
|
||||
case self::STR_TO_TIME:
|
||||
return $this->validatorTimestamp($value);
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/4/20 0020
|
||||
* Time: 17:32
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
* Date: 2018/4/3 0003
|
||||
* Time: 15:46
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace validator;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
@@ -10,7 +11,7 @@ namespace validator;
|
||||
class EnumValidator extends BaseValidator
|
||||
{
|
||||
|
||||
public $value = [];
|
||||
public array $value = [];
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/4/4 0004
|
||||
* Time: 18:44
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
@@ -15,8 +16,8 @@ class IntegerValidator extends BaseValidator
|
||||
const MIN = 'min';
|
||||
const MAX = 'max';
|
||||
|
||||
public $value = null;
|
||||
private $type = '';
|
||||
public ?int $value = null;
|
||||
private string $type = '';
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/4/3 0003
|
||||
* Time: 17:04
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
@@ -17,7 +18,7 @@ class LengthValidator extends BaseValidator
|
||||
|
||||
public $method;
|
||||
|
||||
public $value;
|
||||
public int $value;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
@@ -39,10 +40,8 @@ class LengthValidator extends BaseValidator
|
||||
switch (strtolower($this->method)) {
|
||||
case self::MAX_LENGTH:
|
||||
return $this->maxLength($value);
|
||||
break;
|
||||
case self::MIN_LENGTH:
|
||||
return $this->minLength($value);
|
||||
break;
|
||||
default:
|
||||
return $this->defaultLength($value);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/4/3 0003
|
||||
* Time: 15:47
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/4/4 0004
|
||||
* Time: 18:44
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
@@ -20,11 +21,11 @@ class TypesOfValidator extends BaseValidator
|
||||
const INTEGER = 'integer';
|
||||
const SERIALIZE = 'serialize';
|
||||
|
||||
private $min = null;
|
||||
private $max = null;
|
||||
private ?int $min = null;
|
||||
private ?int $max = null;
|
||||
|
||||
/** @var array */
|
||||
public $types = [
|
||||
public array $types = [
|
||||
self::JSON => 'json',
|
||||
self::FLOAT => 'float',
|
||||
self::ARRAY => 'array',
|
||||
@@ -34,7 +35,7 @@ class TypesOfValidator extends BaseValidator
|
||||
];
|
||||
|
||||
/** @var string */
|
||||
public $method;
|
||||
public string $method;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/10/16 0016
|
||||
* Time: 10:24
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace validator;
|
||||
|
||||
|
||||
+10
-8
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace validator;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
@@ -14,12 +16,12 @@ class Validator extends BaseValidator
|
||||
{
|
||||
|
||||
/** @var BaseValidator[] */
|
||||
private $validators = [];
|
||||
private array $validators = [];
|
||||
|
||||
/** @var Validator */
|
||||
private static $instance = null;
|
||||
/** @var ?Validator */
|
||||
private static ?Validator $instance = null;
|
||||
|
||||
protected $classMap = [
|
||||
protected array $classMap = [
|
||||
'not empty' => [
|
||||
'class' => 'validator\EmptyValidator',
|
||||
'method' => EmptyValidator::CAN_NOT_EMPTY,
|
||||
@@ -31,7 +33,7 @@ class Validator extends BaseValidator
|
||||
'required' => [
|
||||
'class' => 'validator\RequiredValidator',
|
||||
],
|
||||
'enums' => [
|
||||
'enums' => [
|
||||
'class' => 'validator\EnumValidator',
|
||||
],
|
||||
'unique' => [
|
||||
@@ -116,7 +118,7 @@ class Validator extends BaseValidator
|
||||
* @param $field
|
||||
* @param $rules
|
||||
* @return $this
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function make($field, $rules)
|
||||
{
|
||||
@@ -138,7 +140,7 @@ class Validator extends BaseValidator
|
||||
* @param $rule
|
||||
* @param $model
|
||||
* @param $param
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
* ['maxLength'=>150, 'required', 'minLength' => 100]
|
||||
*/
|
||||
public function createRule($field, $rule, $model, $param)
|
||||
@@ -172,7 +174,7 @@ class Validator extends BaseValidator
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function validation()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user