Why use fluent validation
NET, used for building strongly typed validation rules for business objects. Fluent validation is one way of setting up dedicated validator objects, that you would use when you want to treat validation logic as separate from business logic.
Fluent validations use Fluent interface and lambda expressions to build validation rules. Fluent validation is a free-to-use. NET validation library that helps you make your validations clean and easy to both create and maintain. Speed of development- It is easy to work with. Decoupling validation rules and models- Fluent Validation allows you to separate validation rules from your model and helps you structure the rules so that they are nice and readable.
Speed of execution- The rules are immutable objects meaning you can create them once and cache them. Benchmarking showed that we saved considerable time doing this — one import went from a huge amount of time to comparatively very less when we started caching validators. Create a free Team What is Teams? Collectives on Stack Overflow.
Learn more. Why use fluentvalidation instead of ASP. Asked 10 years, 5 months ago. Active 6 years, 8 months ago. Viewed 10k times. Improve this question. DavidS DavidS 2, 3 3 gold badges 24 24 silver badges 42 42 bronze badges. Add a comment. Active Oldest Votes. Improve this answer. Scott Lawrence 6, 12 12 gold badges 44 44 silver badges 62 62 bronze badges. Steve Wilkes Steve Wilkes 6, 3 3 gold badges 28 28 silver badges 31 31 bronze badges.
I often see people over-complicating things and in the real world where one actually has to deliver something at some point it's important to make the solution fit the problem. Yours sounds like a laudably pragmatic approach. Point taken.
However, when you say that "MVC annotation-driven validation is a very 'cheap' way to get some basic validation into an application", I assume that you are talking about out of the box validation i. NOT custom validation. Otherwise, we must be doing something wrong as it's taking us time to get the custom validation going in the MVC way as provided in the link in the OP. In the latter link, there is this separation of concerns that you talk about although of course there are data annotations but the custom validation class itself is separate.
DavidS - I did mean the built-in validator types, yeah - although I assume once you get over the hump of working with custom validators they'd also be pretty cheap to use. FV gives you "a validation system which organises [validators] and plug[s] it all together" via the class-level Validator attributes, which reduces hassle; I'd still say the driving factor in deciding which route to take should be the complexity of the validation required.
Thank you for your answer. We started out with FV but then I made the decision to go and use MVC validation because we require client side validation as well. It might be one of those where only time and experience will tell what is right and what isn't.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
0コメント