Update of /cvsroot/springnet/Spring.Net/doc/reference/src
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv3520
Modified Files:
validation.xml
Log Message:
SPRNET-587 - Add example of validation usage in middle tier services
Index: validation.xml
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/doc/reference/src/validation.xml,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** validation.xml 2 Apr 2008 22:59:54 -0000 1.21
--- validation.xml 3 Apr 2008 02:45:45 -0000 1.22
***************
*** 583,586 ****
--- 583,614 ----
</section>
+ <section>
+ <title>Progammatic usage</title>
+
+ <para>You can also create Validators programmatically using the API. An
+ example is shown below</para>
+
+ <programlisting>UserInfo userInfo = new UserInfo(); // has Name and Password props
+
+ ValidatorGroup userInfoValidator = new ValidatorGroup();
+
+ userInfoValidator.Validators
+ .Add(new RequiredValidator("Name", null));
+
+ userInfoValidator.Validators
+ .Add(new RequiredValidator("Password", null));
+
+ ValidationErrors errors = new ValidationErrors();
+ bool userInfoIsValid = userInfoValidator.Validate(userInfo, errors);
+ </programlisting>
+
+ <para>No matter if you create your validators programmatically or
+ declaratively, you can invoke them in service side code via the 'Validate'
+ method shown above and then handle error conditions. Spring provides AOP
+ parameter validation advice as part of ithe <link
+ linkend="aop-aspect-library">aspect library</link> which may also be
+ useful for performing server-side validation.</para>
+ </section>
+
<section id="validation-aspnet-usage">
<title>Usage tips within ASP.NET</title>
|