We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
版本2.0.9 比如
/** * @IsString(name="expire_at") * @NotEmpty() * @var string * protected $expireAt; */
如果参数中erpireAt == ""的话,只能通过验证的,也即NotEmpty()未生效。
看了源码,在vendor/swoft/validator/src/Validator.php中 第184行
if (!isset($data[$propName]) && !$property['required'] && !isset($property['type']['default'])) { continue; }
此时
$propName == "expireAt"; !isset($data[$propName]) == true; !$property['required'] == true; //非必须 !isset($property['type']['default']); //无默认值
条件成立,跳过此次循环,不会验证是否empty; 应该验证!isset($data[“expire_at”])而非!isset($data[“expireAt”])
将193-201行代码提前至180行即可解决。
The text was updated successfully, but these errors were encountered:
另外文档中说
属性的默认值就是参数的默认值,如果属性没有定义默认值,代表参数没有定义默认值且必须传递
实际没有默认值时也不是必传,必须加上@required()才行
Sorry, something went wrong.
Merge pull request #571 from dyf991645/master
fe82dc3
fix: swoft-cloud/swoft/issues/1266
fe7897d
filx validator has no effect on not required param.
ea7c5bb
stelin
JasonYHZ
Successfully merging a pull request may close this issue.
版本2.0.9
比如
如果参数中erpireAt == ""的话,只能通过验证的,也即NotEmpty()未生效。
看了源码,在vendor/swoft/validator/src/Validator.php中
第184行
此时
条件成立,跳过此次循环,不会验证是否empty;
应该验证!isset($data[“expire_at”])而非!isset($data[“expireAt”])
将193-201行代码提前至180行即可解决。
The text was updated successfully, but these errors were encountered: