Questions tagged [fluentvalidation-2.0]

39 questions
0
votes
1 answer

c# Fluent Validation RuleFor

I am trying to find, if possible, to step into the validator class (MediatR) where Fluent Validation is being used. Something like this: When(x=> x.Count != Null && x.Count >= 0 , () => { RuleFor(x=> x.Offset).Matches(isNumber…
R M
  • 1
0
votes
1 answer

How to Use fluent validation for nullable string?

I have the below code which is throwing an exception for null check: RuleFor(x => x.TestString) .Must(x => !string.IsNullOrEmpty(x)) .When(y => y.OtherArray!= null && y.OtherArray.Count > 0) …
0
votes
1 answer

Using FluentValidation to validate on a collection of Fields (rather than on a validator model)

Im trying to see if there is a way to using FluentValidation without explicitly creating a validation model for every object type in my application. Is this technically and currently possible? Updated To rephrase this, is it possible for…
0
votes
1 answer

Test a Must rule with FluentValidation

I have this rule for validate that a property has a valid value depending on a list of allowed values in another property. model.RuleFor(c => c) .Must(c => string.IsNullOrEmpty(c.CurrentValue) || (!string.IsNullOrEmpty(c.CurrentValue) &&…
0
votes
1 answer

FluentValidation - Validation “leakage” into other replicated models

Current project: ASP.NET 4.5.2 MVC 5 Fluent Validation I may have a very strange issue here. I may be experiencing “Validation Leakage”, whereby validation on one sub-model (which is supposed to be completely filled out) is “leaking over” into the…
0
votes
1 answer

Nested Where(x => x.Condition = value, () => {}); fluentvalidation

Current project: ASP.NET 4.5.1 MVC 5 I need to know if I can nest When() statements like this: When(x => x.Cond1 == val1, () => { When(x => x.SubCond1 == SubVal1, () => { When(x => x.Final1 == finalVal1, () => { …
0
votes
1 answer

Conditional FluentValidation in mvc 4 application

My Model is as below [Validator(typeof(PersonValidator))] public class Person { public string Id { get; set; } public string Name { get; set; } } public class PersonValidator : AbstractValidator { public PersonValidator() …
0
votes
1 answer

Fluent Validation: 'DateTime' does not contain a definition for 'Value'

Trying to make use of Fluent Validation to ensure that a date range is always filled and that the end date does not occur before the beginning date. I have the first part done correctly, and it fires correctly, but the second part seems to be…
0
votes
1 answer

JQuery with Asp.net validation

I have a form that displays an asp.net grid with different people listed in the grid. A user can add new user's to the grid, by clicking an asp.net button on the page:
1 2
3