Closed TorreyGarland closed 10 months ago
@TorreyGarland sorry for taking so long to respond to this.
It seems like you're asking for Fluent API extensions to be added to this plugin, which would do the same thing as the existing .NET data validation attributes (e.g. modelBuilder.Entity<Blog>().Property(b => b.Name).AddUrlValidation()
as an alternative to the [Url]
attribute. I'm not sure that's a great idea... This plugin produces regular expressions specifically to align with the .NET validation behavior of the attributes; once you disconnect from them in the form of a general Fluent API method (e.g. AddUrlValidation()), all sorts of questions can get asked on which exact validation should be performed (see #104 for a sample discussion).
If you really want to avoid specifying check constraints yourself as strings, you can always add your own extension methods (like AddUrlValidation()) which add the check constraint; that would at least concentrate the magic strings in one place, and prevent duplicating them.
I'll go ahead and close this for now, as there's been no user interest in this so far and I'm not sure it's a good idea to do it.
thanks. left that job recently. no longer my problem.
Our team has orders not to use data annotation attributes and Check Constraints can be set up using the fluent configuration, but I hate hard-coded magic strings with a passion.