Updated Wiki: Customising
Overriding the Default Error You can override the default error message for a validator by calling the WithMessage method on a validator definition: RuleFor(customer =>...
View ArticleNew Post: Documentation: DisplayNameAttribute
I accidentally discovered this trying to create a PropertyNameResolver, but FluentValidation already check for System.ComponentModel.DisplayNameAttribute in properties and use that in error messages....
View ArticleUpdated Wiki: Customising
Overriding the Default Error You can override the default error message for a validator by calling the WithMessage method on a validator definition: RuleFor(customer =>...
View ArticleNew Post: Documentation: DisplayNameAttribute
I've added this to the docs. Thanks for the suggestion.
View ArticleUpdated Wiki: Customising
Overriding the Default Error You can override the default error message for a validator by calling the WithMessage method on a validator definition: RuleFor(customer =>...
View ArticleUpdated Wiki: Customising
Overriding the Default Error You can override the default error message for a validator by calling the WithMessage method on a validator definition: RuleFor(customer =>...
View ArticleNew Post: Count invalid items in a model
Simple validation, loops over all the boxes and makes sure you enter something into at least one of them. RuleFor(model => model.AnyInvoicesEntered) .NotEmpty() .When(AtLeastOneValueEntered)...
View ArticleNew Post: Validating Object Graphs
I see how you can re-use a validator for Complex Properties and Collections, but how will it work when the reference is bi-directional? Will the example below produce an infinite loop, and if so what...
View ArticleNew Post: Idea for integration
You could probably use T4 templates to generate your validation classes. Look at the Reverse Engineer Code First in Entity Framework Power Tools. It gives you the option to generate your model,...
View ArticleNew Post: Validating Object Graphs
Update: I just tried this and got a StackOverflow exception like I expected. Is there a feature/setting that I'm missing that makes this work? Maybe by using the When method? It seems like a person...
View ArticleNew Post: Validating Object Graphs
Hi Yes, this will indeed cause a stackoverflow. Your best bet is either to remove one of the calls to SetValidator, and perform the validation manually when necessary or put one of the SetValidator...
View ArticleNew Post: Count invalid items in a model
Hi This message isn't coming from FluentValidation, but rather from MVC itself. Before ASP.NET MVC invokes validation, it will first check to see if the property can be set to the value. If it can't,...
View ArticleNew Post: Validating Object Graphs
It appears the StackOverflow is happening in the constructor while wiring up the validators instead of in the validators themselves. Is it possible to mark an entity as validated so it doesn't wire up...
View ArticleNew Post: Passing an object while validating
Hi Jeremy, Thanks for this wonderful library. I have been using it extensively for my project. I have a query which I have been not able to resolve. I have a requirement, where I am editing an object...
View ArticleNew Post: Validation Rule for overall model
I just ran into a need for this as well. I'm trying to perform validation that determines if a record has been entered twice. It needs to checks if three properties match the same three properties of...
View ArticleNew Post: Passing an object while validating
Hi Amit FluentValidation isn't really designed to work this way - all the context should be driven by properties on the object you're validating, not by passing in anything extra. The best way to do...
View ArticleNew Post: Validating Object Graphs
Hmm yes, so this does happen in the validator's constructor, not actually at the time of validation, so marking the entity itself as already validated won't actually help. Essentially your validator...
View ArticleNew Post: Validation of object hierarchy
I have this object hierarchy: Tab -> LayoutContainer -> PropertyField where LayoutContainer and PropertyField is abstract classes. I would like to create validator's for LayoutContainer and...
View ArticleNew Post: Non-property oriented validation
I have a requirement to make a validation that is not connected with any particular property but depends for example... on the state of the whole application/object etc. Is FluentValidation supplying...
View Article