-
-
Notifications
You must be signed in to change notification settings - Fork 364
perf(RequiredValidator): call GetLocalizerErrorMessage after validate failed #4996
New issue
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
Conversation
…lidator 在验证未出结果之前(结果必定为通过)本地化包含自定义内容的 ErrorMessage 且其内容中有不符合 string.Format 方法要求的内容(如:ErrorMessage = $"当前 {{{nameof(MenuType)}}} 的值必须要设置 {{0}} 。")时导致程序崩溃问题。
自定义验证方法会正确处理 {{{nameof(MenuType)}}} 自定义内容。
Reviewer's Guide by SourceryThis pull request optimizes the Sequence diagram for optimized RequiredValidator validation flowsequenceDiagram
participant C as Client
participant V as RequiredValidator
participant VC as ValidationContext
C->>+V: Validate(propertyValue, context, results)
alt propertyValue is null
V->>V: GetValidationResult(context)
V->>VC: GetValidationResult(errorMessage)
VC-->>V: ValidationResult
V->>V: results.Add(ValidationResult)
else propertyValue is empty string
V->>V: GetValidationResult(context)
V->>VC: GetValidationResult(errorMessage)
VC-->>V: ValidationResult
V->>V: results.Add(ValidationResult)
else propertyValue is empty IEnumerable
V->>V: GetValidationResult(context)
V->>VC: GetValidationResult(errorMessage)
VC-->>V: ValidationResult
V->>V: results.Add(ValidationResult)
end
V-->>-C: void
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Thanks for your PR, @AiYuZhen. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AiYuZhen - I've reviewed your changes - here's some feedback:
Overall Comments:
- The
System.Security.AccessControlusing statement appears to be unused and can be removed.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4996 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 630 630
Lines 27922 27928 +6
Branches 3996 3996
=========================================
+ Hits 27922 27928 +6 ☔ View full report in Codecov by Sentry. |
# Conflicts: # src/BootstrapBlazor/BootstrapBlazor.csproj Co-Authored-By: AiZhen <[email protected]>
|
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AiYuZhen - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
2a3b559
fix(RequiredValidator):优化 ValidationResult 生成代码
Summary of the changes (Less than 80 chars)
简单描述你更改了什么, 不超过80个字符;如果有关联 Issue 请在下方填写相关编号
优化
public override void Validate(object? propertyValue, ValidationContext context, List<ValidationResult> results)方法,只有在验证不通过时才执行创建ValidationResult的相关格式化代码。fixes #4997
Regression?
[If yes, specify the version the behavior has regressed from]
[是否影响老版本]
Risk
[Justify the selection above]
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Bug Fixes:
Summary by Sourcery
Bug Fixes:
Validatemethod to improve performance by generatingValidationResultonly when necessary.