1

I ran into issue validating dates in my application. There are approximately 40 models with maybe a few dozen date fields between them. I have custom validations assigned to many models via attributes, and they are working very well. However, I want to step it up, and add a custom validation to an entire data type system-wide. So that I can be sure that all existing dates and all date fields in any class which may be added in the future are restricted in the same way, and the restriction is centralized.

I looked into System.Web.MVC.ClientCadaTypeModelValidatorProvider here: https://github.com/aspnet/AspNetWebStack/blob/42991b3d2537b702736463f76a10a4fcf2ea44c9/src/System.Web.Mvc/ClientDataTypeModelValidatorProvider.cs in hopes that I might deduce how to extend it with custom validation logic, however, I'm not smart enough to figure it out on my own.

How can I possibly attach a custom validator not to a particular field via explicit attribute assignment, but to an entire data type indiscriminately?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.