php-validate icon indicating copy to clipboard operation
php-validate copied to clipboard

Lightweight and feature-rich PHP validation and filtering library. Support scene grouping, pre-filtering, array checking, custom validators, custom messages. 轻量且功能丰富的PHP验证、过滤库。支持场景...

Results 15 php-validate issues
Sort by recently updated
recently updated
newest added
trafficstars

https://github.com/inhere/php-validate/blob/d93a21a7a5031d256dc5dd9a929d4a7f613dfece/src/Validator/GlobalMessage.php#L76-L77 这个提示语等于暴露了允许的值。 --- inField 验证器没有提示语 https://github.com/inhere/php-validate/blob/e900a44a36098360481a69dfb0571a90027d395f/src/Traits/ScopedValidatorsTrait.php#L575-L582

enhancement

这不知道是不是bug? 改用translates做了解决。 ``` $v = \Inhere\Validate\Validation::make(data: [ 'title' => '', 'name' => '', ], rules: array( ['title,name', 'required', 'msg' => [ 'tagId' => '标题不能为空。', 'userId' => '姓名不能为空。', ]], ))->validate( stopOnError:...

help wanted

``` requiredIf requiredUnless requiredWith requiredWithAll requiredWithout requiredWithoutAll ``` 比如注册表单中的手机号和邮箱,选填其一。 该如何设置必填项?下面这种可以吗? ``` ['email', 'requiredWithoutAll', ['phone']], ['email', "string:6,50", 'filter' => $filter], ['email', 'email'], ['phone', 'requiredWithoutAll', ['email']], ['phone', "fixedSize:11", 'filter' => $filter], ['phone',...

question

https://github.com/inhere/php-validate/blob/5ff992659db20c3af8fc7247b1d45a0ccf224b8b/src/Validator/GlobalMessage.php#L68-L73 {value0} 应该是 {attr1} 因为 $translates 第二个参数名称没有被翻译

``` $MultipleRules = [ ['captchaCode', 'fixedSize:4', 'msg' => $msg], ['username', 'required|string:3,15|regexp:{$regexp["username"]}', 'msg' => $msg], // ['username', 'required|string:3,15|regexp:^[a-zA-Z]\w{4,19}$', 'msg' => $msg], ['password', 'required|string:8,20|regexp:{$regexp["password"]}', 'msg' => $msg], ]; ``` 比如说 {$regexp["username"]} 不能这么写吗?

question

能不能直接在项目里放一些最小的功能示例? 然后再慢慢扩展了解。 一上来看一堆功能,不容易了解。

question

```php // src/Traits/ScopedValidatorsTrait.php public function requiredIf(string $field, $fieldVal, string $anotherField, $values): ?bool { // 此处验证二维数组字段时,$anotherField可能时‘test.field1’, isset为false if (isset($this->data[$anotherField])) { $anotherVal = $this->data[$anotherField]; // if (in_array($anotherVal, (array)$values, true)) { if (Helper::inArray($anotherVal,...

https://github.com/inhere/php-validate/blob/master/src/ValidationTrait.php#L311 如上,`safe`的独立分支(标记安全的字段不需要其他验证),但是这个分支导致了 后续的`after`不可用 https://github.com/inhere/php-validate/blob/3749f60dffaaaeb288bf256d096af9bd41ddd975/src/ValidationTrait.php#L316-L323 如上`required`的分支是出于什么考虑?

question

Hi ! Thank you for this lib ! Is there a way to combine eachValidator with FieldValidation and filters ? Perhaps with something like this : ``` $v = Inhere\Validate\FieldValidation::check(['array'...

enhancement

类似这样的设计, ``` $rules = [ 'rule0'=>['field0', 'validator'], 'rule1'=>['field1', 'validator'], 'rule2'=>['field2', 'validator'] ] $scenes = [ 'scene0'=>['rule0', 'rule3'], 'scene1'=>['rule1', 'rule3'], ] ``` 如此,即可取代on的设计,在使用的时候更加灵活