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

Commented Issue: Problem with a Must overload. [7131]

$
0
0
I'm having trouble using the following overload:
```
Must<T, TProperty>(Func<TProperty, bool> predicate)
```

The presence of the generic T in the method definition prevents concise usage such as:
```
RuleFor(x => x.Title).Must(s => !string.IsNullOrWhiteSpace(s) || s.Length == 0);
```
Instead I must type:
```
RuleFor(x => x.Title).Must((string s) => !string.IsNullOrWhiteSpace(s) || s.Length == 0);
```
The class being validated (T) is not used anywhere in the predicate and can be removed from the method signature.
Comments: Which version of visual studio are you seeing the intellisense issue in? I'm running 2012 Pro and don't see this problem at all. Do you have any other code analysis tools installed that could be causing this?

Viewing all articles
Browse latest Browse all 1917


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