q
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Inject\Route\LocalService;
|
||||
use ReflectionException;
|
||||
use Kiri\Inject\Route\Container;
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class Email implements ValidatorInterface
|
||||
@@ -22,19 +19,12 @@ class Email implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
$service = Container::getContext()->get(LocalService::class)->get('request');
|
||||
if ($service->isPost) {
|
||||
return filter_var($service->post($name, null), FILTER_VALIDATE_EMAIL);
|
||||
} else {
|
||||
return filter_var($service->query($name, null), FILTER_VALIDATE_EMAIL);
|
||||
}
|
||||
return filter_var($class->{$name}, FILTER_VALIDATE_EMAIL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class Ignore implements ValidatorInterface
|
||||
@@ -8,12 +10,12 @@ class Ignore implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class In implements ValidatorInterface
|
||||
@@ -16,12 +18,12 @@ class In implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return in_array($class->{$name}, $this->value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class Length implements ValidatorInterface
|
||||
@@ -16,12 +18,13 @@ class Length implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return mb_strlen($class->{$name}) === $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class Max implements ValidatorInterface
|
||||
@@ -17,12 +18,13 @@ class Max implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return $class->{$name} <= $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class MaxLength implements ValidatorInterface
|
||||
@@ -16,12 +18,13 @@ class MaxLength implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return mb_strlen($class->{$name}) <= $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class Min implements ValidatorInterface
|
||||
@@ -17,12 +18,13 @@ class Min implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return $class->{$name} >= $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class MinLength implements ValidatorInterface
|
||||
@@ -16,12 +18,13 @@ class MinLength implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return mb_strlen($class->{$name}) <= $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class Must implements ValidatorInterface
|
||||
{
|
||||
@@ -17,13 +19,14 @@ class Must implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return $class->{$name} === $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class NotEmpty implements ValidatorInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return !empty($class->{$name});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
@@ -17,12 +19,13 @@ class NotIn implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return !in_array($class->{$name}, $this->value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class NotNull implements ValidatorInterface
|
||||
@@ -8,12 +10,13 @@ class NotNull implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return $class->{$name} !== null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Inject\Route\LocalService;
|
||||
use ReflectionException;
|
||||
use Kiri\Inject\Route\Container;
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class Phone implements ValidatorInterface
|
||||
@@ -13,20 +10,12 @@ class Phone implements ValidatorInterface
|
||||
const REG = '/^1[356789]\d{9}$/';
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
$service = Container::getContext()->get(LocalService::class)->get('request');
|
||||
if ($service->isPost) {
|
||||
$data = $service->post($name, null);
|
||||
} else {
|
||||
$data = $service->query($name, null);
|
||||
}
|
||||
return preg_match(self::REG, $data);
|
||||
return preg_match(self::REG, $class->{$name});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class Required implements ValidatorInterface
|
||||
{
|
||||
|
||||
|
||||
public function dispatch(string $name): bool
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return true;
|
||||
return $class->$name === null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Inject\Validator\Inject;
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class Round implements ValidatorInterface
|
||||
@@ -17,12 +18,13 @@ class Round implements ValidatorInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(string $name): bool
|
||||
public function dispatch(object $class, string $name): bool
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
return round($name, $this->value) == $name;
|
||||
return round($class->$name, $this->value) === $class->$name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user