是否可以使用Blazor / EditForm有条件的Required DataAnnotation进行验证?

时间:2020-06-05 20:01:35

标签: c# .net blazor

现在我的模型课中有类似的内容:

        [Required]
        public bool IsNullable { get; set; }

        [Required]
        [StringLength(255, ErrorMessage = "Default value is too long.")]
        public string DefaultValue { get; set; }

我想拥有它,以便仅当isNullable为false时才需要DefaultValue。有没有办法做到这一点?我一直在寻找解决方案,但仍然找不到任何有用的方法。谢谢您的时间。

0 个答案:

没有答案