From bc5d983361c87b46b20c60a71a8e393d6e817205 Mon Sep 17 00:00:00 2001 From: inhere Date: Thu, 30 Nov 2017 20:10:25 +0800 Subject: [PATCH] some update. add more validators test, add new validator: numList --- README.md | 55 ++++++++++++------ composer.json | 2 +- src/Filter/FilterList.php | 30 ++++++++++ src/Utils/ErrorMessageTrait.php | 4 +- src/Utils/Helper.php | 19 +++++-- src/ValidationTrait.php | 15 ++--- src/ValidatorList.php | 96 ++++++++++++++++++++++---------- tests/ValidatorListTest.php | 99 +++++++++++++++++++++++++++++++++ 8 files changed, 259 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 69156bf..b923073 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![License](https://img.shields.io/packagist/l/inhere/php-validate.svg?style=flat-square)](LICENSE) [![Php Version](https://img.shields.io/badge/php-%3E=7.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/inhere/php-validate) [![Latest Stable Version](http://img.shields.io/packagist/v/inhere/php-validate.svg)](https://packagist.org/packages/inhere/php-validate) -[![git branch](https://img.shields.io/badge/branch-php5-yellow.svg)](https://github.com/inhere/php-validate) +[![git branch](https://img.shields.io/badge/branch-master-yellow.svg)](https://github.com/inhere/php-validate) 一个简洁小巧且功能完善的php验证、过滤库。仅有几个文件,无依赖。 @@ -16,7 +16,7 @@ - 方便的获取错误信息,验证后的安全数据获取 - 已经内置了40多个常用的验证器[内置验证器](#built-in-validators) - 规则设置参考自 yii 的。部分规则参考自 laravel -- `RuleValidation` 规则配置类似于Yii: 每条规则中,允许多个字段,但只能有一个验证器。 +- `Validation/RuleValidation` 规则配置类似于Yii: 每条规则中,允许多个字段,但只能有一个验证器。 - e.g `['tagId,userId,name,email,freeTime', 'required', ...]`(下面的示例都是这种) - `FieldValidation` 规则配置类似于Laravel: 每条规则中,只能有一个字段,但允许多个验证器。 - e.g `['field', 'required|string:5,10|...', ...]` @@ -25,8 +25,8 @@ ## 项目地址 -- **git@osc** https://gitee.com/inhere/php-validate.git - **github** https://github.com/inhere/php-validate.git +- **git@osc** https://gitee.com/inhere/php-validate.git **注意:** @@ -35,7 +35,14 @@ ## 安装 -- 使用 composer +- 使用 composer 命令 + +```php +composer require inhere/php-validate +// composer require inhere/php-validate ^2.2 +``` + +- 使用 composer.json 编辑 `composer.json`,在 `require` 添加 @@ -49,8 +56,8 @@ - 直接拉取 ``` -git clone https://git.oschina.net/inhere/php-validate.git // git@osc git clone https://github.com/inhere/php-validate.git // github +git clone https://gitee.com/inhere/php-validate.git // git@osc ``` ## 使用 @@ -63,7 +70,6 @@ git clone https://github.com/inhere/php-validate.git // github > 此方式是最为完整的使用方式 ```php - use Inhere\Validate\Validation; class PageRequest extends Validation @@ -82,7 +88,7 @@ class PageRequest extends Validation ['username', 'string', 'on' => 'scene2' ], ['username', 'regexp' ,'/^[a-z]\w{2,12}$/'], ['title', 'customValidator', 'msg' => '{attr} error msg!' ], // 指定当前规则的消息 - ['status', function($status) { + ['status', function($status) { // 直接使用闭包验证 if (is_int($status) && $status > 3) { return true; } @@ -108,7 +114,7 @@ class PageRequest extends Validation ]; } - // 自定义验证器的提示消息, 更多请看 {@see ValidationTrait::$messages} + // 自定义验证器的提示消息, 默认消息请看 {@see ErrorMessageTrait::$messages} public function messages() { return [ @@ -169,7 +175,7 @@ class SomeController } ``` -### 方式 1: 创建一个新的class,使用 ValidationTrait +### 方式 3: 创建一个新的class,使用 ValidationTrait 创建一个新的class,并使用 Trait `Inhere\Validate\ValidationTrait`。 此方式是高级自定义的使用方式, 可以方便的嵌入到其他类中 @@ -244,7 +250,6 @@ class UserController } ``` - ## 添加自定义验证器 - 在继承了 `Inhere\Validate\Validation` 的子类添加验证方法. 请看上面的 **使用方式1** @@ -559,8 +564,10 @@ public function get(string $key, $default = null) `float` | 过滤非法字符,保留`float`格式的数据 | `['price', 'float', 'filter' => 'float'],` `string` | 过滤非法字符并转换为`string`类型 | `['userId', 'number', 'filter' => 'string'],` `trim` | 去除首尾空白字符,支持数组。 | `['username', 'min', 4, 'filter' => 'trim'],` -`lowercase` | 字符串转换为小写 | `['description', 'min', 4, 'filter' => 'lowercase'],` -`uppercase` | 字符串转换为大写 | `['title', 'min', 4, 'filter' => 'uppercase'],` +`lowercase` | 字符串转换为小写 | `['description', 'string', 'filter' => 'lowercase'],` +`uppercase` | 字符串转换为大写 | `['title', 'string', 'filter' => 'uppercase'],` +`snakeCase` | 字符串转换为蛇形风格 | `['title', 'string', 'filter' => 'snakeCase'],` +`camelCase` | 字符串转换为驼峰风格 | `['title', 'string', 'filter' => 'camelCase'],` `timestamp/strToTime` | 字符串日期转换时间戳 | `['pulishedAt', 'number', 'filter' => 'strToTime'],` `abs` | 返回绝对值 | `['field', 'int', 'filter' => 'abs'],` `url` | URL 过滤,移除所有不符合 URL 的字符 | `['field', 'url', 'filter' => 'url'],` @@ -590,6 +597,7 @@ public function get(string $key, $default = null) `isList` | 验证值是否是一个自然数组 list (key是从0自然增长的) | `['tags', 'isList']` `isArray` | 验证是否是数组 | `['goods', 'isArray']` `intList` | 验证字段值是否是一个 int list | `['tagIds', 'intList']` +`numList` | 验证字段值是否是一个 number list | `['tagIds', 'numList']` `strList` | 验证字段值是否是一个 string list | `['tags', 'strList']` `min` | 最小边界值验证 | `['title', 'min', 40]` `max` | 最大边界值验证 | `['title', 'max', 40]` @@ -624,7 +632,7 @@ public function get(string $key, $default = null) `md5` | 验证是否是 md5 格式的字符串 | `['passwd', 'md5']` `sha1` | 验证是否是 sha1 格式的字符串 | `['passwd', 'sha1']` `color` | 验证是否是html color | `['backgroundColor', 'color']` -`regexp` | 使用正则进行验证 | `['name', 'regexp', '/^\w+$/']` +`regex/regexp` | 使用正则进行验证 | `['name', 'regexp', '/^\w+$/']` `safe` | 用于标记字段是安全的,无需验证 | `['createdAt, updatedAt', 'safe']` ### `safe` 验证器,标记属性/字段是安全的 @@ -658,6 +666,7 @@ $v = Validation::make($_POST, [ - 关于布尔值验证 * 如果是 "1"、"true"、"on" 和 "yes",则返回 TRUE * 如果是 "0"、"false"、"off"、"no" 和 "",则返回 FALSE +- `size/range` `length` 可以只定义 `min` 最小值。 但是 **当定义了 `max` 值时,必须同时定义最小值** - 支持对数组的子级值验证 ```php @@ -676,9 +685,7 @@ $v = Validation::make($_POST, [ ``` - `required*` 系列规则参考自 laravel -- 验证大小范围 `int` 是比较大小。 `string` 和 `array` 是检查长度 -- `size/range` `length` 可以只定义 `min` 最小值。 但是 **当定义了 `max` 值时,必须同时定义最小值** -- 验证大小范围 是包含边界值的 +- 验证大小范围 `int` 是比较大小。 `string` 和 `array` 是检查长度。大小范围 是包含边界值的 ## 代码示例 @@ -687,9 +694,23 @@ $v = Validation::make($_POST, [ ## 单元测试 ```sh -./tests/test.sh +phpunit ``` ## License MIT + +## 我的其他项目 + +### `inhere/console` [github](https://github.com/inhere/php-console) [git@osc](https://git.oschina.net/inhere/php-console) + +轻量且功能丰富的命令行应用,工具库, 控制台交互. + +### `inhere/sroute` [github](https://github.com/inhere/php-srouter) [git@osc](https://git.oschina.net/inhere/php-srouter) + +轻量且快速的路由库 + +### `inhere/http` [github](https://github.com/inhere/php-http) [git@osc](https://git.oschina.net/inhere/php-http) + +http message 工具库(PSR 7 实现) diff --git a/composer.json b/composer.json index 64f216d..0a30ea9 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "inhere/php-validate", "type": "library", - "description": "a simple validate library of the php", + "description": "a simple validate, filter library of the php", "keywords": ["library", "validate"], "homepage": "http://github.com/inhere/php-validate", "license": "MIT", diff --git a/src/Filter/FilterList.php b/src/Filter/FilterList.php index dca3811..b787d2d 100644 --- a/src/Filter/FilterList.php +++ b/src/Filter/FilterList.php @@ -138,6 +138,36 @@ public static function uppercase($var) return Helper::strToUpper($var); } + /** + * string to snakeCase + * @param string $var + * @param string $sep + * @return string + */ + public static function snakeCase($var, $sep = '_') + { + if (!$var || !\is_string($var)) { + return ''; + } + + return Helper::toSnakeCase($var, $sep); + } + + /** + * string to camelcase + * @param string $var + * @param bool $ucFirst + * @return string + */ + public static function camelCase($var, $ucFirst = false) + { + if (!$var || !\is_string($var)) { + return ''; + } + + return Helper::toCamelCase($var, $ucFirst); + } + /** * string to time * @param string $var diff --git a/src/Utils/ErrorMessageTrait.php b/src/Utils/ErrorMessageTrait.php index d9b5025..a0c1ff5 100644 --- a/src/Utils/ErrorMessageTrait.php +++ b/src/Utils/ErrorMessageTrait.php @@ -65,6 +65,7 @@ trait ErrorMessageTrait '{attr} must be a string and minimum length be {min}', '{attr} must be a string and length range must be {min} ~ {max}', ], + 'regex' => '{attr} does not match the {value0} conditions', 'regexp' => '{attr} does not match the {value0} conditions', 'mustBe' => '{attr} must be equals to {value0}', @@ -79,6 +80,7 @@ trait ErrorMessageTrait 'isMap' => '{attr} must be an array and is key-value format', 'isList' => '{attr} must be an array of nature', 'intList' => '{attr} must be an array and value is all integers', + 'numList' => '{attr} must be an array and value is all numbers', 'strList' => '{attr} must be an array and value is all strings', 'json' => '{attr} must be an json string', @@ -376,7 +378,7 @@ public function getTranslate(string $attr): string { $trans = $this->getTranslates(); - return $trans[$attr] ?? Helper::toSnakeCase($attr, ' '); + return $trans[$attr] ?? Helper::beautifyFieldName($attr); } /** diff --git a/src/Utils/Helper.php b/src/Utils/Helper.php index 205ec94..693a240 100644 --- a/src/Utils/Helper.php +++ b/src/Utils/Helper.php @@ -214,14 +214,14 @@ public static function ucwords($str) * Translates a string with underscores into camel case (e.g. first_name -> firstName) * @prototype string public static function toCamelCase(string $str[, bool $capitalise_first_char = false]) * @param $str - * @param bool $upper_case_first_char + * @param bool $upperCaseFirstChar * @return mixed */ - public static function toCamelCase($str, $upper_case_first_char = false) + public static function toCamelCase($str, $upperCaseFirstChar = false) { $str = self::strToLower($str); - if ($upper_case_first_char) { + if ($upperCaseFirstChar) { $str = self::ucfirst($str); } @@ -243,6 +243,17 @@ public static function toSnakeCase($string, $sep = '_') return self::strToLower(trim(preg_replace('/([A-Z][a-z])/', $sep . '$1', $string), $sep)); } + /** + * @param string $field + * @return mixed|string + */ + public static function beautifyFieldName($field) + { + $str = self::toSnakeCase($field, ' '); + + return strpos($str, '_') ? str_replace('_', ' ', $str) : $str; + } + /** * getValueOfArray 支持以 '.' 分割进行子级值获取 eg: 'goods.apple' * @param array $array @@ -272,7 +283,7 @@ public static function getValueOfArray(array $array, $key, $default = null) } /** - * @param $cb + * @param callable $cb * @param array $args * @return mixed * @throws \InvalidArgumentException diff --git a/src/ValidationTrait.php b/src/ValidationTrait.php index f24ccb5..a3c44ee 100644 --- a/src/ValidationTrait.php +++ b/src/ValidationTrait.php @@ -16,7 +16,7 @@ /** * Trait ValidationTrait * @package Inhere\Validate - * @property array $data To verify the data list. please define it on main class. 待验证的数据列表 + * property array $data To verify the data list. please define it on main class. 待验证的数据列表 */ trait ValidationTrait { @@ -34,11 +34,8 @@ trait ValidationTrait */ protected $scene = ''; - /** - * Through the validation of the data - * @var array - */ - private $_safeData = []; + /** @var array used rules at current scene */ + protected $_usedRules = []; /** * the rules is by setRules() @@ -47,10 +44,10 @@ trait ValidationTrait private $_rules = []; /** - * used rules at current scene + * Through the validation of the data * @var array */ - protected $_usedRules = []; + private $_safeData = []; /** @var bool */ private $_validated = false; @@ -185,7 +182,7 @@ public function validate(array $onlyChecked = null, $stopOnError = null) continue; } - // clear all options + // clear all keywords options unset($rule['msg'], $rule['default'], $rule['skipOnEmpty'], $rule['isEmpty'], $rule['when'], $rule['filter']); // 验证设置, 有一些验证器需要参数。 e.g. size() diff --git a/src/ValidatorList.php b/src/ValidatorList.php index 08177eb..35c32f4 100644 --- a/src/ValidatorList.php +++ b/src/ValidatorList.php @@ -226,18 +226,17 @@ public static function alphaDash($val) */ public static function size($val, $min = null, $max = null) { - $options = []; - - if (\is_int($val)) { - $val = (int)$val; - } elseif (\is_string($val)) { - $val = Helper::strlen(trim($val)); - } elseif (\is_array($val)) { - $val = \count($val); - } else { - return false; + if (!\is_int($val)) { + if (\is_string($val)) { + $val = Helper::strlen(trim($val)); + } elseif (\is_array($val)) { + $val = \count($val); + } else { + return false; + } } + $options = []; $minIsNum = is_numeric($min); $maxIsNum = is_numeric($max); @@ -302,7 +301,7 @@ public static function notBe($val, $excepted) /** * 最小值检查 - * @param int $val + * @param int|string|array $val * @param integer $minRange * @return bool */ @@ -313,7 +312,7 @@ public static function min($val, $minRange) /** * 最大值检查 - * @param int $val + * @param int|string|array $val * @param int $maxRange * @return bool */ @@ -359,7 +358,7 @@ public static function regexp($val, $regexp, $default = null) $options['default'] = $default; } - return filter_var($val, FILTER_VALIDATE_REGEXP, ['options' => $options]); + return (bool)filter_var($val, FILTER_VALIDATE_REGEXP, ['options' => $options]); } public static function regex($val, $regexp, $default = null) @@ -376,7 +375,7 @@ public static function regex($val, $regexp, $default = null) * FILTER_FLAG_HOST_REQUIRED - 要求 URL 包含主机名(比如 http://www.example.com) * FILTER_FLAG_PATH_REQUIRED - 要求 URL 在域名后存在路径(比如 www.example.com/example1/test2/) * FILTER_FLAG_QUERY_REQUIRED - 要求 URL 存在查询字符串(比如 "example.php?name=Peter&age=37") - * @return mixed + * @return bool */ public static function url($val, $default = null, $flags = 0) { @@ -390,14 +389,14 @@ public static function url($val, $default = null, $flags = 0) $settings['flags'] = $flags; } - return filter_var($val, FILTER_VALIDATE_URL, $settings); + return (bool)filter_var($val, FILTER_VALIDATE_URL, $settings); } /** * email 地址验证 * @param string $val 要验证的数据 * @param mixed $default 设置验证失败时返回默认值 - * @return mixed + * @return bool */ public static function email($val, $default = null) { @@ -407,7 +406,7 @@ public static function email($val, $default = null) $options['default'] = $default; } - return filter_var($val, FILTER_VALIDATE_EMAIL, ['options' => $options]); + return (bool)filter_var($val, FILTER_VALIDATE_EMAIL, ['options' => $options]); } /** @@ -419,7 +418,7 @@ public static function email($val, $default = null) * FILTER_FLAG_IPV6 - 要求值是合法的 IPv6 IP(比如 2001:0db8:85a3:08d3:1319:8a2e:0370:7334) * FILTER_FLAG_NO_PRIV_RANGE - 要求值不在 RFC 指定的私有范围 IP 内(比如 192.168.0.1) * FILTER_FLAG_NO_RES_RANGE - 要求值不在保留的 IP 范围内。该标志接受 IPV4 和 IPV6 值 - * @return mixed + * @return bool */ public static function ip($val, $default = null, $flags = 0) { @@ -433,7 +432,7 @@ public static function ip($val, $default = null, $flags = 0) $settings['flags'] = $flags; } - return filter_var($val, FILTER_VALIDATE_IP, $settings); + return (bool)filter_var($val, FILTER_VALIDATE_IP, $settings); } /** @@ -472,7 +471,7 @@ public static function isArray($val) /** * 验证值是否是一个非自然数组 map (key - value 形式的) - * @param array $val + * @param mixed $val * @return bool */ public static function isMap($val) @@ -481,6 +480,7 @@ public static function isMap($val) return false; } + /** @var array $val */ foreach ($val as $k => $v) { if (\is_string($k)) { return true; @@ -492,7 +492,7 @@ public static function isMap($val) /** * 验证值是否是一个自然数组 list (key是从0自然增长的) - * @param array $val + * @param array|mixed $val * @return bool */ public static function isList($val) @@ -503,6 +503,7 @@ public static function isList($val) $prevKey = 0; + /** @var array $val */ foreach ($val as $k => $v) { if (!\is_int($k)) { return false; @@ -520,16 +521,21 @@ public static function isList($val) /** * 验证字段值是否是一个 int list - * @param array $val + * @param array|mixed $val * @return bool */ public static function intList($val) { - if (!\is_array($val)) { + if (!$val || !\is_array($val)) { return false; } - foreach ($val as $v) { + /** @var array $val */ + foreach ($val as $k => $v) { + if (!\is_int($k)) { + return false; + } + if (!is_numeric($v)) { return false; } @@ -538,18 +544,48 @@ public static function intList($val) return true; } + /** + * 验证字段值是否是一个 number list + * @param array|mixed $val + * @return bool + */ + public static function numList($val) + { + if (!$val || !\is_array($val)) { + return false; + } + + /** @var array $val */ + foreach ($val as $k => $v) { + if (!\is_int($k)) { + return false; + } + + if (!is_numeric($v) || $v <= 0) { + return false; + } + } + + return true; + } + /** * 验证字段值是否是一个 string list - * @param array $val + * @param array|mixed $val * @return bool */ public static function strList($val) { - if (!\is_array($val)) { + if (!$val || !\is_array($val)) { return false; } - foreach ($val as $v) { + /** @var array $val */ + foreach ($val as $k => $v) { + if (!\is_int($k)) { + return false; + } + if (\is_string($v)) { return true; } @@ -758,7 +794,8 @@ public static function afterOrEqualDate($val, $afterDate) */ public static function isDateFormat($date) { - return (bool)preg_match('/^([\d]{4})-((0?[\d])|(1[0-2]))-((0?[\d])|([1-2][\d])|(3[01]))( [\d]{2}:[\d]{2}:[\d]{2})?$/', $date); + return (bool)preg_match('/^([\d]{4})-((0?[\d])|(1[0-2]))-((0?[\d])|([1-2][\d])|(3[01]))( [\d]{2}:[\d]{2}:[\d]{2})?$/', + $date); } /** @@ -768,7 +805,8 @@ public static function isDateFormat($date) */ public static function isDate($date) { - if (!preg_match('/^([\d]{4})-((?:0?[\d])|(?:1[0-2]))-((?:0?[\d])|(?:[1-2][\d])|(?:3[01]))( [\d]{2}:[\d]{2}:[\d]{2})?$/', $date, $matches)) { + if (!preg_match('/^([\d]{4})-((?:0?[\d])|(?:1[0-2]))-((?:0?[\d])|(?:[1-2][\d])|(?:3[01]))( [\d]{2}:[\d]{2}:[\d]{2})?$/', + $date, $matches)) { return false; } diff --git a/tests/ValidatorListTest.php b/tests/ValidatorListTest.php index f06cb5c..7681ab0 100644 --- a/tests/ValidatorListTest.php +++ b/tests/ValidatorListTest.php @@ -118,4 +118,103 @@ public function testLength() $this->assertTrue(ValidatorList::length('test', 3, 5)); $this->assertTrue(ValidatorList::length([3, 'test', 'hi'], 2, 5)); } + + public function testRegexp() + { + $this->assertFalse(ValidatorList::regexp('test', '/^\d+$/')); + $this->assertFalse(ValidatorList::regexp('test-dd', '/^\w+$/')); + + $this->assertTrue(ValidatorList::regexp('test56', '/^\w+$/')); + } + + public function testUrl() + { + $this->assertFalse(ValidatorList::url('test')); + $this->assertFalse(ValidatorList::url('/test56')); + + $this->assertTrue(ValidatorList::url('http://a.com/test56')); + } + + public function testEmail() + { + $this->assertFalse(ValidatorList::email('test')); + $this->assertFalse(ValidatorList::email('/test56')); + + $this->assertTrue(ValidatorList::email('abc@gmail.com')); + } + + public function testIp() + { + $this->assertFalse(ValidatorList::ip('test')); + $this->assertFalse(ValidatorList::ip('/test56')); + + $this->assertTrue(ValidatorList::ip('0.0.0.0')); + $this->assertTrue(ValidatorList::ip('127.0.0.1')); + } + + public function testIsArray() + { + $this->assertFalse(ValidatorList::isArray('test')); + $this->assertFalse(ValidatorList::isArray(345)); + + $this->assertTrue(ValidatorList::isArray([])); + $this->assertTrue(ValidatorList::isArray(['a'])); + } + + public function testIsMap() + { + $this->assertFalse(ValidatorList::isMap('test')); + $this->assertFalse(ValidatorList::isMap([])); + $this->assertFalse(ValidatorList::isMap(['abc'])); + + $this->assertTrue(ValidatorList::isMap(['a' => 'v'])); + $this->assertTrue(ValidatorList::isMap(['value', 'a' => 'v'])); + } + + public function testIsList() + { + $this->assertFalse(ValidatorList::isList('test')); + $this->assertFalse(ValidatorList::isList([])); + $this->assertFalse(ValidatorList::isList(['a' => 'v'])); + $this->assertFalse(ValidatorList::isList(['value', 'a' => 'v'])); + + $this->assertTrue(ValidatorList::isList(['abc'])); + $this->assertTrue(ValidatorList::isList(['abc', 565, null])); + } + + public function testIntList() + { + $this->assertFalse(ValidatorList::intList('test')); + $this->assertFalse(ValidatorList::intList([])); + $this->assertFalse(ValidatorList::intList(['a', 'v'])); + $this->assertFalse(ValidatorList::intList(['a' => 'v'])); + $this->assertFalse(ValidatorList::intList(['value', 'a' => 'v'])); + + $this->assertTrue(ValidatorList::intList(['343', 45])); + $this->assertTrue(ValidatorList::intList([565, 3234, -56])); + } + + public function testNumList() + { + $this->assertFalse(ValidatorList::numList('test')); + $this->assertFalse(ValidatorList::numList([])); + $this->assertFalse(ValidatorList::numList(['a', 'v'])); + $this->assertFalse(ValidatorList::numList(['a' => 'v'])); + $this->assertFalse(ValidatorList::numList(['value', 'a' => 'v'])); + $this->assertFalse(ValidatorList::numList([565, 3234, -56])); + + $this->assertTrue(ValidatorList::numList(['343', 45])); + $this->assertTrue(ValidatorList::numList([56, 45])); + } + + public function testStrList() + { + $this->assertFalse(ValidatorList::strList('test')); + $this->assertFalse(ValidatorList::strList([])); + $this->assertFalse(ValidatorList::strList(['a' => 'v'])); + + $this->assertTrue(ValidatorList::strList(['value', 'a' => 'v'])); + $this->assertTrue(ValidatorList::strList(['abc'])); + $this->assertTrue(ValidatorList::strList(['abc', 565, null])); + } }