Dashboard > WebWork > ... > FAQ > Why do some validators like stringlength ignore validation when input is empty, it worked before
  WebWork Log In View a printable version of the current page.  
  Why do some validators like stringlength ignore validation when input is empty, it worked before
Added by tm_jee, last edited by Philip Luppens on Apr 11, 2007  (view change) show comment
Labels: 
(None)

Note

This behavior is added since WebWork 2.2.4 (in the XWork bundle that comes with it). See XW-422 for more information.

WebWork's validators are designed to be as independent of each other as possible, such that a validator like 'stringlength' should just validate the lenght of the input string. It will not attempt to validate an empty string as that would overlap with the 'requiredstring' validator, for example.

If we need to validate against an input that should not be empty and should have a certain length, we would apply the following validator sequence :

  • 'requiredstring' validator
  • 'stringlength' validator

If we need to validate against an input that should have a certain length but it doesn't matter if nothing is specified, we could apply the following validator sequence :

  • 'stringlength' validator

Without the concept of 'independent responsibility' in each validator design, the second case in the above described senarios would not be possible to achieve.

For more information about validators, have a look at Validation.

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators