Results 1 to 5 of 5

Thread: Why aren't there any good VaLang examples/tutorials.

  1. #1

    Default Why aren't there any good VaLang examples/tutorials.

    Hello,
    I admit to being new to spring, and I am looking to validate a simple form. When I saw how VaLang works, by not having to define a validation bean but instead just create an expression to validate a bean I got pretty excited. Finally, a simple, fast, and easy validation procedure.

    however, i can not get VaLang working. i downloading spring-modules 0.8, and i have scoured the net for a decent tutorial on server side validation, however i can not find one that explains things well enough. Hopefull this forum can help me out.

    I understand that in my *-servlet.xml file i should add something like this.

    [code]
    <bean id="myValidator" class="org.springmodules.validation.valang.ValangV alidator">
    <property name="valang">
    <value><![CDATA[
    { firstName : length(?) < 30 : 'First name too long' }
    { lastName : length(?) < 50 : 'Last name too long' }
    ]]></value>
    </property>
    </bean>
    [code]


    However, on my form, how do i ensure that the input fields firstName and lastName are subjected to this type of validation. Also, for multiple forms, do i just continue to fill the properties field with more names and validation conditions?

    Any tutorial that will clearly explain how to use valang would be appreciated. I just need to know what to add in my *-servlet.xml file, anything to the controller class, and what to add on the view to ensure it gets validated.

    I appreciate the help. THANKS! THANKS!

  2. #2

    Default

    I surfed the net and tried so many different tutorials.
    for those who need it, The one that I followed to the T, and had it work successfully is this.

    http://www.i-proving.ca/space/Techno...MVC/Validation

    good luck to those embarking on valang. It is great once you figure out how it works.

  3. #3

    Default

    netvampire can you please provide me sample code of working example...
    It will be a gr8 help


    Regards,

  4. #4

    Default

    I hope this helps.

    In my dispatcher-servlet.xml file i have this type of validation working with valang

    Code:
        <bean id="registrationValidator" class="org.springmodules.validation.valang.ValangValidator">
            <property name="valang">
                <value><![CDATA[
                { userName : ? is not blank : 'User Name: required.' }
                { userName : matches('\\w+',?) == true: 'User Name: Only Alpha-Numeric Characters' }
                { userName : matches('\\w+',?) == true: 'User Name: Only Alpha-Numeric Characters' }
                { userName : length(?) > 6 : 'User Name: Not between 6 - 12 characters.' }            
                { userName : length(?) < 12 : 'User Name: Not between 6 - 12 characters.' }            
                { firstName : ? is not blank : 'First Name: required.' }
                { firstName : matches('\\w+',?) == true: 'First Name: Only Alpha-Numeric Characters' }
                { lastName : ? is not blank : 'Last Name: required.' }
                { lastName : matches('\\w+',?) == true: 'Last Name: Only Alpha-Numeric Characters' }
                { email : ? is not blank : 'E-Mail: required.' }
                { email : email(?) == true: 'E-Mail: Not A valid Address' }
                { password : ? is not blank : 'Password: required.' }
                { password : matches('\\w+',?) == true: 'Password: Only Alpha-Numeric Characters' }
                { password : length(?) > 6 : 'Password: Not between 6 - 12 characters.' }            
                { password : length(?) < 12 : 'Password: Not between 6 - 12 characters.' }            
                { confirmPassword : ? is not blank : 'Confirm Password: required.' }
                { confirmPassword : matches('\\w+',?) == true: 'Confirm Password: Only Alpha-Numeric Characters' }
                { city : ? is not blank : 'City: required.' }
                { age : matches('\\d+',?) == true: 'Age: Only Numeric Characters' }
                { age : ? is not blank : 'Age: required.' }
                ]]></value>
            </property>
        </bean>
    You may also need the correct library files to get this going (not sure, can't remember).

    Hope it helps.

  5. #5
    Join Date
    Oct 2007
    Posts
    15

    Default

    Hi everyone, you can get good Valang examples from the ¨Expert Spring MVC and Web flow¨ book. they are covering valang in a good level, so I suggest you to take a look at it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •