I had an interesting problem at work the other day.
I needed to perform a number of validations against an object, and report a single error message.
In this project we're using Spring.net's validation framework.
Out of the box, spring.net validation doesn't provide any easy way to report a single error for multiple validations. But here's a simple trick to work around this:
1. Use a validation group to group all the validations.
2. Don't include an action (message) on the included validations.
3. Set the group's 'Actions' property to a new list of Spring.Validation.Actions.ErrorMessageAction items.
<v:group>
<v:property name="Actions">
<list>
<object type="Spring.Validation.Actions.ErrorMessageAction">
<constructor-arg index="0" value="error.MyError" />
<constructor-arg index="1" value="MyErrorParam" />
</object>
</list>
</v:property>
<v:validator test="Prop1" />
<v:validator test="Prop2" />
<v:validator test="Prop3" />
</v:group>
Subscribe to:
Post Comments (Atom)
A short list of C# coding issues.
Injecting services into entities It been bugging me for a while now that to use services in a entity can be a bit of pain. It usually starts...
-
Many developers that I work with avoid working with msbuild. This is a shame, since a little msbuild knowledge can go a long way. Her...
-
Recently I needed to create a link to edit a content item in Orchard . Orchard uses a url like http://mysite/Home/Admin/Contents/Edit/ 12...
-
Context: I have been a (proud) Windows fanboy since Win3.11. At Uni I studied physics, by the end of my masters, I knew I wanted to be a dev...
No comments:
Post a Comment