PDA

View Full Version : Newbie : Example for Validation Framework with config file


Gaurang
02-07-2007, 04:56 PM
I know this is silly question but this is very important for me. I have gone through all available post related to validation framework but i have not got any hint to solve my problem. so this post. :(

As document says, i should be able to use Validation Framework from any application layer. I am interested in invoking this validation framework from my BLC to validate the message object. I have define my XML file, but now I am not getting any idea about how to use this xml file and invoke validation.

It will be great if somebody provide me an example to use this xml config file for validation. Below is my sample xml file, now tell me how can i invoke this validatio from my BLC. Thanks in advance.

<objects xmlns="http://www.springframework.net" xmlns:v="http://www.springframework.net/validation">
<v:group id="tripValidator">
<v:required id="RequiredFieldValidator" test="SimpleMessage.RField">
<v:message id="error.departureAirport.required" providers="departureAirportErrors, validationSummary"/>
</v:required>
</v:group>
</objects>

Gaurang
02-07-2007, 07:18 PM
:D .

I started analyzing ValidationConfigParser and got confused. Use GetObject method and now every thing is working fine.

Thanks to Spring.Net team for this wonderful stuff. I love it.

But I still think it would be great if someone can elaborate all the components of validation framework in detail.

Thanks.
Gaurang

Aleks Seovic
02-07-2007, 10:24 PM
Hi Gaurang,

You are right, validation foramework reference docs (http://www.springframework.net/doc-latest/reference/html/validation.html) do not provide any information on how to work with validators programmatically or how to access validators defined in the application context.

As you figured out, answer to the second question is simple -- you access them as any other object defined in the context, by injecting validator reference into another object or by calling IApplicationContext.GetObject(validatorId) method.

We will expand reference docs to include the missing information, thanks for pointing this out.

Regards,

Aleks