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

New Post: Best way to apply global/default rules for primitive (string) types

$
0
0
Hi folks,

We're wanting to enforce some global rules for string inputs (basically a regex match to prevent malicious input), and then allow the validators to override it on specific fields if needed. What's the best way to approach this? I've looked at
  • PropertyValidator, but you have to call SetValidator on each field
  • AbstractValidator<string>, but this doesn't seem to get picked up and run
At the moment, I'm thinking we'll have to use a Base class that all our validators inherit from, reflect over the validation type and add our custom validation rules for any public string properties. But I'm hoping there might be a nicer way?

Thanks

J

Viewing all articles
Browse latest Browse all 1917

Trending Articles



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