jbogard / ContosoUniversityCore

MIT License
590 stars 150 forks source link

Question: How are the validators called? #12

Closed nojaf closed 7 years ago

nojaf commented 7 years ago

I can't put my finger on it but what part of the code will actually trigger the Validator class in ContosoUniversityCore/src/ContosoUniversityCore/Features/Student/Create.cs?

I'm guessing you override some ModelStateValidator somewhere but I can't seem to tell where.

jbogard commented 7 years ago

Not magic! https://github.com/jbogard/ContosoUniversityCore/blob/master/src/ContosoUniversityCore/Startup.cs#L40

Everything is set up in the Startup class (which I quite like for how explicit it is).

You'll see tho a lot of library authors are building extensions to make adding it all one liners.

nojaf commented 7 years ago

So this will make sure that the matching AbstractValidator is found and executed for any incoming T model?

jbogard commented 7 years ago

Yep!