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

Commented Issue: Validator doesn't check target against Null [7123]

$
0
0
Hello,

Excuse me, if I'm conceptually wrong but shouldn't validator check that target instance is not null?
As far as I can see in code, the check is being made only in explicit IValidator.Validate method implementation, and if the following test is added to AbstractValidatorTester, it fails:

```
[Test]
public void When_instanse_is_null_Should_throw_argumentnullexception() {
typeof(ArgumentNullException).ShouldBeThrownBy(() =>
validator.Validate((Person)null));
}
```
P.S.
Actually, I was wondering how to validate the target itself against Null in addition to property validation rules, but failed to figure out while reading the documentation and browsing the samples. Could you please share the best approach?

Thanks.
Comments: Thank you, Jeremy

Viewing all articles
Browse latest Browse all 1917

Trending Articles



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