DefaultValidatorProvider - Parametric/Simple.Validation GitHub Wiki

Simple.Validation requires that you register your validators with the static Validator class via an instance of IValidatorProvider. A DefaultValidatorProvider is available for use in the core library, though IValidatorProvider is a simple interface to implement. For Dependency Injection purposes a sample NinjectValidatorProvider is provided in the Simple.Validation.Ninject package.

Here is a sample of what a configuration might look like at application startup.

    public class Configuration
    {
        public void ConfigureValidation()
        {
            var validatorProvider = CreateValidatorProvider();
            RegisterValidators(validatorProvider);
            Validator.SetValidatorProvider(validatorProvider);
        }

        private static void RegisterValidators(DefaultValidatorProvider validatorProvider)
        {
            validatorProvider.RegisterValidator(new SaveLoanApplicationValidator());
            validatorProvider.RegisterValidator(new SubmitLoanApplicationValidator());
        }

        private static DefaultValidatorProvider CreateValidatorProvider()
        {
            var validatorProvider = new DefaultValidatorProvider();
            return validatorProvider;
        }
    }
⚠️ **GitHub.com Fallback** ⚠️