Example #1
0
        private IEnumerable <ModelValidationResult> ValidateUserModel(UserModel user)
        {
            var metadata = ModelMetadataProviders.Current.GetMetadataForProperty(() => user.Login, typeof(UserModel), "Login");

            var dataAnnotationValidator = new DryIocDataAnnotationsModelValidator(_serviceProvider, metadata,
                                                                                  new ControllerContext(),
                                                                                  new RequiredAttribute());

            return(dataAnnotationValidator.Validate(user));
        }
Example #2
0
        private IEnumerable <ModelValidationResult> ValidateLoginModel(LoginModel login)
        {
            var metadata = ModelMetadataProviders.Current.GetMetadataForType(() => login, typeof(LoginModel));

            var dataAnnorationValidator = new DryIocDataAnnotationsModelValidator(_serviceProvider, metadata,
                                                                                  new ControllerContext(),
                                                                                  new VerifyLoginValidationAttribute());

            return(dataAnnorationValidator.Validate(login));
        }