c# - Is it best practice to do data validation inside a command validation? -


i using specexpress command validation.(command validation validates command before goes controller.)

for simple case validated length, required or not, regular expressions etc. situation below:

check command property eg. "username" in database or not, scenario, using repository , check data in database or not, if exists failed or success.

this.check(ur => ur.username).required().expect(             (x, y) =>                 {                     var isexists = userservice.isexists(x.username);                     return !isexists;                 },              "user exist"); 

my question that, best practice data validation inside command validation?
or in conventional way in controller or service check user in database or not move next step or throw exception.

we(my team) normal validation check @ command validation , type of data validation goes controller or service.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -