Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b9940509a9 | |||
| 12848dd71d | |||
| 4e34436231 | |||
| 722b9060d0 | |||
| 92604bf0c1 | |||
| 4b383027f8 | |||
| f644821230 | |||
| 67ff141afe | |||
| 7a4cce7343 | |||
| adc310cf21 |
@@ -7,6 +7,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
interface IFormat
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param $result
|
||||
* @return ResponseInterface
|
||||
|
||||
@@ -10,6 +10,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
class MixedFormat implements IFormat
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var ResponseInterface
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
class OtherFormat implements IFormat
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var ResponseInterface
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
class ResponseFormat implements IFormat
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param $result
|
||||
* @return ResponseInterface
|
||||
|
||||
@@ -9,6 +9,7 @@ use Swoole\Http\Response;
|
||||
interface OnRequestInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
|
||||
@@ -64,6 +64,9 @@ class Binding implements RequestFilterInterface
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
$array = [];
|
||||
if (count($this->rules) < 1) {
|
||||
return $array;
|
||||
}
|
||||
foreach ($this->rules as $key => $rule) {
|
||||
if (is_string($key)) {
|
||||
$array[] = $this->getValidator($key, $rule);
|
||||
@@ -91,7 +94,7 @@ class Binding implements RequestFilterInterface
|
||||
if (is_numeric($key)) {
|
||||
$class = self::TYPES[$rule];
|
||||
} else {
|
||||
$class = array_merge(self::TYPES[$key], ['value' => $rule, 'field' => $key]);
|
||||
$class = array_merge(self::TYPES[$key], ['value' => $rule, 'field' => $key]);
|
||||
}
|
||||
$isFirst = false;
|
||||
if ($class['class'] === RequiredValidatorFilter::class) {
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace Kiri\Router\Validator;
|
||||
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_PROPERTY)]
|
||||
class Ignoring
|
||||
{
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class BetweenValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class InValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class LengthValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class MaxLengthValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class MaxValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class MinLengthValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class MinValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class MustValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class NotBetweenValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class NotInValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
|
||||
class PhoneValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
const string REG = '/^1[356789]\d{9}$/';
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Validator\RequestFilter;
|
||||
class RoundValidatorFilter extends ValidatorFilter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
|
||||
@@ -91,6 +91,9 @@ class Validator
|
||||
*/
|
||||
public function addRule(string $name, array $rule): void
|
||||
{
|
||||
if (count($rule) < 1) {
|
||||
return;
|
||||
}
|
||||
if (!isset($this->rules[$name])) {
|
||||
$this->rules[$name] = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user