fluentvalidation-2.0

Fluent validation with dynamic message

风格不统一 提交于 2019-12-13 13:07:45
问题 I am trying to building custom validation with dynamic message in fluent validation library. For example : public class CreateProcessValidator : AbstractValidator<CreateProcessVM> { public CreateProcessValidator() { RuleFor(x => x.ProcessFile).Must((x,e) => IsProcessFileValid(x.ProcessFile))).WithMessage("Parse failed with error : {0}"); } public bool IsProcessFileValid(HttpPostedFileBase file) { var errorMessage = "..." // pass result to validaton message ? // logic return false; } } Is here

Using FluentValidation to validate on a collection of Fields (rather than on a validator model)

流过昼夜 提交于 2019-12-13 02:53:55
问题 Im trying to see if there is a way to using FluentValidation without explicitly creating a validation model for every object type in my application. Is this technically and currently possible? Updated To rephrase this, is it possible for FluentValidation to validate Rules WITHOUT a IValidator context? Instead, i would like to pass in the item instance to be validated and use validation Rules which are constructed on-the-fly. Resolved I was able to resolve by doing a kind of a hack solution.

Clientside validation attributes on hidden,radio, dropdown elements by default in asp.net mvc 3

孤街浪徒 提交于 2019-12-08 08:48:25
问题 I'm using ASP.NET MVC 3 + FLUENT VALIDATION + NINJECT I have model X and rules for that model are something like this: RuleFor(c => c.FirstName).NotEmpty(); RuleFor(c => c.LastName).NotEmpty(); I spotted a little strange thing, the engine puts validation attributes on all hidden elements and on dropdowns, radio buttons, etc.., and I didn't specified this in the validation configuration for that model, so I guess it is by default... <input type="hidden" value="1" name="Id" id="Id" data-val

What is the correct way to register FluentValidation with SimpleInjector?

拟墨画扇 提交于 2019-12-04 11:48:22
问题 I am able to register FluentValidation AbstractValidators using a FluentValidatorFactory . However, it doesn't feel right, because not all of the IoC container registrations happen during bootstrap / composition root. Instead, the fluent validators are registered by a separate factory: The composition root : public class SimpleDependencyInjector : IServiceProvider { public readonly Container Container; public SimpleDependencyInjector() { Container = Bootstrap(); } internal Container Bootstrap

What is the correct way to register FluentValidation with SimpleInjector?

守給你的承諾、 提交于 2019-12-03 07:12:46
I am able to register FluentValidation AbstractValidators using a FluentValidatorFactory . However, it doesn't feel right, because not all of the IoC container registrations happen during bootstrap / composition root. Instead, the fluent validators are registered by a separate factory : The composition root : public class SimpleDependencyInjector : IServiceProvider { public readonly Container Container; public SimpleDependencyInjector() { Container = Bootstrap(); } internal Container Bootstrap() { var container = new Container(); container.Register< // ...register all non-fluent-validator

Why use fluentvalidation instead of ASP.NET MVC validation

假装没事ソ 提交于 2019-12-03 05:38:47
问题 In which circumstances would you choose FluentValidation (FV) over the ASP.NET MVC 3 way? What are the advantages of FV over MVC? I realise that with the latter we have to write much more code and can litter the code with Data Annotations. Moreover, it would seem to be easier to write custom validation using FV than MVC. However, with MVC it is possible to make use the data annotation and plug jQuery validation in. So what in your view would make you choose one over the other? Are there

Why use fluentvalidation instead of ASP.NET MVC validation

穿精又带淫゛_ 提交于 2019-12-02 18:59:43
In which circumstances would you choose FluentValidation (FV) over the ASP.NET MVC 3 way ? What are the advantages of FV over MVC? I realise that with the latter we have to write much more code and can litter the code with Data Annotations. Moreover, it would seem to be easier to write custom validation using FV than MVC. However, with MVC it is possible to make use the data annotation and plug jQuery validation in. So what in your view would make you choose one over the other? Are there circumstances where you would even use both? Steve Wilkes Fluent validation is one way of setting up