Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

Commented Issue: FluentValidationModelMetadataProvider not setting 'IsRequired' property in ModelMetadata when I set something as NotNull [7054]

$
0
0
For example,
RuleFor(q => q.Name).NotNull().WithMessage("Name is required");

should, in my opinion, set the IsRequired property. This is important to me because I use that property to see if I should add an asterisk to a field when auto-generating it.

Thanks,

Ryan
Comments: I have hit this same scenario in mvc5, is it a bug . RuleFor(c => c.UserName).NotEmpty(); and in the Editor template var metadata = ModelMetadata.FromStringExpression("", ViewData); var t = (metadata == null || metadata.DataTypeName == null) ? "text" : metadata.DataTypeName; if (metadata.IsRequired) { <span class="required">*</span> } if so, can i do any thing using IValidatorInterceptor.

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>