Injecting services into ValidationAttributes in ASP.NET Core

added by DotNetKicks
9/29/2016 7:09:17 PM

657 Views

I was battling the other day writing a custom DataAnnotations ValidationAttribute, where I needed access to a service class to perform the validation. The documentation on creating custom attributes is excellent, covering both server side and client side validation, but it doesn't mention this, presumably relatively common, requirement.


0 comments