Issue Details (XML | Word | Printable)

Key: VALIDATOR-189
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Niall Pemberton
Reporter: tomster
Votes: 0
Watchers: 0
Operations

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

Validating array integers fails

Created: 30/May/06 12:29 PM   Updated: 12/Nov/07 07:25 PM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 1.3.1 Release

Time Tracking:
Not Specified

Environment: Tomcat 5.5.17, Struts 1.2.9 (default validator 1.1.4 and 1.3.0)

Resolution Date: 31/May/06 12:58 AM


 Description  « Hide
I posted this issue on Struts and it got determined to be a validator bug (or appears to be).

There seems to be some issue with validating integer arrays:

html:

<html:select property="types" multiple="true" size="3" >
<html:option value="1">should work</html:option>
<html:option value="2">should work as well</html:option>
<html:option value="blah">this will fail validation</html:option>
</html:select>

actionform:

public class PropertyFilter implements Serializable
{
private String[] types;

public String[] getTypes() { return types; }
public void setTypes(String[] types) { this.types = types; }
}

validation.xml:

<formset>
<form name="PropertyFilterForm">

<field property="types" depends="integer">
<arg0 key="text.validation.type"/>
</field>

</form>
</formset>

Even if all values are integer, it will fail validation regardless. According to http://www.strutskickstart.com/IndexedPropertiesandValidation.ppt#18 I should
do something like:

<field property="types" indexedListProperty="types" depends="integer">
<arg0 key="text.validation.type"/>
</field>

This time, it does indeed check all the values are of type integer, however,
if you do not select anything (the field is not required) the result is:

java.lang.NullPointerException
org.apache.commons.validator.Field.getIndexedProperty(Field.java:796)
org.apache.commons.validator.Field.validate(Field.java:891)
..

Also having scoured all documentation in current and future builds and there is no example of validating an integer array.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.