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

New Post: Help with chaining custom validator

$
0
0

Your extension method hasn't been defined properly in the sample project. 

- The ValidationExtensions class must be static

- The EnsureValidDate8601 method must be static

- The extension method must have the "this" prefix on the first parameter.

After fixing these problems it compiles fine. Here's what the code should look like:

 

public static class ValidationExtensions
{
    public static IRuleBuilderOptions<T, string> EnsureValidDate8601<T>(this IRuleBuilder<T, string> ruleBuilder)
    {
        return ruleBuilder.SetValidator(new ValidDate8601());
    }
}

 


Viewing all articles
Browse latest Browse all 1917

Trending Articles



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