Stripes

@Validate should support trim

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: Release 1.4.3
  • Fix Version/s: Release 1.5
  • Component/s: Validation
  • Labels:
    None
  • Environment:
    All

Description

The maxlength and minlength @Validate parameters include any leading and trailing whitespace when they calculate the length of a field, similarly the required parameter will treat a field containing just spaces as if it is valid. To rectify this, it is proposed to add a new boolean parameter to @Validate: trim. If set, the contents of the field will be trimmed of leading and trailing spaces before performing the other validation checks.

Activity

Hide
Jakub Exner added a comment - 20/Apr/08 11:23 AM

I'd like to have a global option, perhaps in web.xml, to enable this behavior by default. The "trim" parameter of @Validate could override this global option (i.e. false to true or true to false).

Show
Jakub Exner added a comment - 20/Apr/08 11:23 AM I'd like to have a global option, perhaps in web.xml, to enable this behavior by default. The "trim" parameter of @Validate could override this global option (i.e. false to true or true to false).
Hide
Ben Gunter added a comment - 09/May/08 10:46 PM

Values are always trimmed by default during validation, type conversion and binding. This behavior can be overridden by setting @Validate(trim=false). For reasons that have been explained in depth on the mailing list, there will be no global option to turn this behavior on or off. If someone finds that they need to revert to the old behavior, then they can override DefaultActionBeanPropertyBinder.trim(String[], ValidationMetadata) to simply return the value unchanged.

Show
Ben Gunter added a comment - 09/May/08 10:46 PM Values are always trimmed by default during validation, type conversion and binding. This behavior can be overridden by setting @Validate(trim=false). For reasons that have been explained in depth on the mailing list, there will be no global option to turn this behavior on or off. If someone finds that they need to revert to the old behavior, then they can override DefaultActionBeanPropertyBinder.trim(String[], ValidationMetadata) to simply return the value unchanged.

People

Vote (0)
Watch (1)

Dates

  • Created:
    02/Apr/08 5:58 AM
    Updated:
    04/Jan/11 2:49 PM
    Resolved:
    09/May/08 10:46 PM