Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-397

Allow default values if validation fails

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.5.1
    • Fix Version/s: None
    • Component/s: Routines
    • Labels:
      None

      Description

      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) {
          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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sergiocg80 Sergio

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment