eee
This commit is contained in:
+4
-9
@@ -34,18 +34,13 @@ abstract class BaseValidator
|
||||
|
||||
|
||||
/**
|
||||
* @param $field
|
||||
* @param $message
|
||||
* @param string $field
|
||||
* @param string $message
|
||||
* @return bool
|
||||
*/
|
||||
public function addError($field, $message): bool
|
||||
public function addError(string $field, string $message): bool
|
||||
{
|
||||
if (!is_null($field)) {
|
||||
$message = str_replace(':attribute', $field, $message);
|
||||
}
|
||||
|
||||
$this->message = $message;
|
||||
|
||||
$this->message = str_replace(':attribute', $field, $message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,46 +38,46 @@ class DateTimeValidator extends BaseValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*
|
||||
* 效验分秒 格式如 01:02 or 01-02
|
||||
*/
|
||||
public function validatorTime($value): bool
|
||||
public function validatorTime(string $value): bool
|
||||
{
|
||||
return (bool)preg_match('/^\d{2}:\d{2}(:\d{2})?+(\.\d+)?$/', $value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*
|
||||
* 效验分秒 格式如 2017-12-22 01:02
|
||||
*/
|
||||
public function validateDatetime($value): bool
|
||||
public function validateDatetime(string $value): bool
|
||||
{
|
||||
return (bool)preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?+(\.\d+)?$/', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*
|
||||
* 效验分秒 格式如 2017-12-22
|
||||
*/
|
||||
public function validatorDate($value): bool
|
||||
public function validatorDate(string $value): bool
|
||||
{
|
||||
return (bool)preg_match('/^\d{4}-\d{2}-\d{2}$/', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param string|int $value
|
||||
* @return bool
|
||||
*
|
||||
* 效验时间戳 格式如 1521452254
|
||||
*/
|
||||
public function validatorTimestamp($value): bool
|
||||
public function validatorTimestamp(string|int $value): bool
|
||||
{
|
||||
return (bool)preg_match('/^1\d{9}$/', $value);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ class Validator extends BaseValidator
|
||||
return [Kiri::createObject($defined), 'trigger'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ModelInterface $model
|
||||
* @return bool
|
||||
|
||||
Reference in New Issue
Block a user