You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sergio (JIRA)" <ji...@apache.org> on 2016/06/30 13:53:10 UTC

[jira] [Created] (VALIDATOR-397) Allow default values if validation fails

Sergio created VALIDATOR-397:
--------------------------------

             Summary: Allow default values if validation fails
                 Key: VALIDATOR-397
                 URL: https://issues.apache.org/jira/browse/VALIDATOR-397
             Project: Commons Validator
          Issue Type: Improvement
          Components: Framework
    Affects Versions: 1.5.1
            Reporter: Sergio
            Priority: Minor


Hi, I'm new to Commons Validator. Sometimes I need to provide a default value if a validation fails.

{{Integer val = IntegerValidator.getInstance().validate(str);}}
{{if (val == null) {}}
{{&nbsp;&nbsp;&nbsp;&nbsp;val = 0;}}
{{}}}

Or

{{Integer val = (Integer) ObjectUtils.defaultIfNull(IntegerValidator.getInstance().validate(str), 0);}}

I think it would be great if a default value could be provided as a second parameter in the method {{validate}}

If you find it useful, I will be glad to submit a patch to contribute. I've almost never done a contribution (some little patches to JBoss JPBM time ago) and I think that this would be a nice place to start again.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)