Skip to content

override ValidationResult IsValid 方法在 BootstrapInput 的ValidateRules 中不生效 #3598

Answered by ArgoZhang
guijunhua asked this question in Q&A
Discussion options

You must be logged in to vote
public class ValueCheckAttribute : ValidationAttribute
{
    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        return new ValidationResult($"The {validationContext.DisplayName} field must be a future date.", ["age"]);
    }
}

你需要指定是那个字段的报错

这个问题,我考虑一下,我还是决定内置一个逻辑,我修复一下,如果没有指定,我就用当前字段

帮忙点一下下面的那个按钮让这个回答标记为答案

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ArgoZhang
Comment options

Answer selected by guijunhua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Question that needs to be answered need-repro-project Need repro project
2 participants
Converted from issue

This discussion was converted from issue #3593 on May 30, 2024 07:53.