Issue Details (XML | Word | Printable)

Key: GDS-971
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Franck Wolff
Reporter: Nicolas Couturier
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
GraniteDS

Bean Validation generated regexp invalid on Flex side with escaped super-sequences / predefined character classes

Created: 04/Feb/12 06:18 PM   Updated: 07/Feb/12 03:11 PM   Resolved: 07/Feb/12 03:11 PM
Component/s: AS3 code generation
Affects Version/s: 2.3.0.GA
Fix Version/s: 2.3.1.GA

Environment: Win XP or Mac OS 10.7.2 - Maven 3.0.3 - Java 1.6


 Description  « Hide
Predefined character classes such as \s, \d or \w, when escaped for use in bean validation annotations on Java side (i.e. \\s, \\d or \\w) are not escaped on the AS3 generated validation annotations (and thus validation with FormValidator fails).

Example:
Java side
============
    // 'Hi' followed by a repetition of words separated by a space; "Hi dude" should work
    @Basic
    @NotNull(message="cannot be null")
    @Pattern(regexp="^Hi( \\w)*$", message="invalid format")
    private String message;

generated AS3 side
============
    [NotNull(message="cannot be null")]
    [Pattern(message="invalid format", regexp="^Hi( \w)*$")]
    public function get message():String {
        return _message;
    }

When entering a string such as "Hi dude" FormValidator fails validation.

Sample project (including code above) based on org.graniteds.archetypes:graniteds-tide-spring-jpa-hibernate:1.1.0.GA available here: http://enjoii.free.fr/example1.tar.gz
Steps to reproduce bug:
1. tar -zxf example1
2. cd example1
3. mvn clean install
4. cd webapp
5. mvn jetty:run-war
6. http://localhost:8080/example1/example1.swf
7. login with admin/admin
8. enter "Hi dude" in message text field
=> textfield goes red with "invalid format" message

Franck Wolff added a comment - 05/Feb/12 03:23 PM
Should be fix in the next nightly build (#150).

Thanks.

Nicolas Couturier added a comment - 06/Feb/12 10:43 AM
Fix worked for me (note that I corrected my Java side regexp as well):
For Java side @Pattern(regexp="^Hi( \\w+)*$", message="invalid format")
AS3 generated side is [Pattern(message="invalid format", regexp="^Hi( \\w+)*$")]
Which makes the validation succeed on entering "Hi dude".

Franck Wolff added a comment - 07/Feb/12 03:11 PM
Fixed.