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

New Post: Best practices to invoke validate

$
0
0
I'm confused about what is the best way to call the validator. From within my method of business or outside.

example:

invoke at controller:
var uow = UnitOfWorkFactory.GetInstance();
var userBLL= new UserBLL(uow);
var validator = new UserValidator(userBLL);
var user = .....;
validator.Validade(user);
if (validator.IsValid) {
    ....
}
else {
    ....
}
or at business layer:
var uow = UnitOfWorkFactory.GetInstance();
var userBLL= new UserBLL(uow);

try {
   var user = .....;
   // Inside of the method "Save" I create and invoke the validator adding the result in a exception.
   userBLL.Save(user);
}
catch {
   /// Error of the validator
}
What is the best way? Or there are other options?

Thanks
[]s

Viewing all articles
Browse latest Browse all 1917

Trending Articles



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