Closed gkfischer closed 4 years ago
These are database configurations, and not fluent validations. Does your web application register them in the ModelState, when you try to make a normal web request?
Nothing special done to register them, it's just an alternative way to specify restrictions on properties, like described here: https://docs.microsoft.com/en-us/ef/core/modeling/. When running the app these are added as validations to the ModelState.
I will take a look. Maybe it is some sort of misconfiguration on the library's end.
Thanks
I am not quite sure about this because I tried to reproduce it and the ModelState does not consider the IEntityTypeConfiguration fluent validation as I expected and it stays valid. These interface and configuration are database related. If you ModelState shows errors, you are configuring validation from somewhere else. I am attaching a solution, in which I am trying to reproduce your issue but cannot. Could you send me a solution sample of some sort so that I can take a look?
I can do that over the weekend. Time's running out today
@gkfischer No worries, I will leave the issue open. Waiting for your input and will assist you as soon as possible. Thank you!
Ok, to make a long story short: my mistake. The fluent validations are only used by EF but not by the MVC framework. Strange design, as the DataAnnotations on the properties are used by both. But anyway, everythings fine when adding something like https://docs.fluentvalidation.net/en/latest/index.html.
All my validations on model classes are defined as fluent validations in OnModelCreating of the DataContext and not as attributes on the properties of the models, like so:
But these validation rules are not loaded as it seems when the test framework runs as the ModelState collection doesn't contain any entries. How can I get the framework to load them?