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

[validator] Syntax/logic errors in UrlValidator javadoc example

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • None
    • None
    • None
    • Operating System: Windows XP
      Platform: PC

    • 37192

    Description

      This is in commons-validator 1.1.4, plus jakarta-oro 2.0.8 (for Perl). Also
      applies to cv 1.1.3, the earliest publically-available cv with UrlValidator

      The examples given in the commons UrlValidator javadoc are syntactically and
      logically flawed.

      Syntactically the jd code is incorrect in that the UrlValidator is spelled
      Urlvalidator.

      Reproduce:

      According to the javadoc, the following code:

      public static void main(String[] args) {
      String[] schemes =

      {"http","https"}

      ;
      UrlValidator urlValidator = new UrlValidator(schemes);
      if (urlValidator.isValid("ftp"))

      { System.out.println("url is valid"); } else { System.out.println("url is invalid"); }

      UrlValidator urlValidator2 = new UrlValidator();
      if (urlValidator2.isValid("ftp")) { System.out.println("url is valid"); }

      else

      { System.out.println("url is invalid"); }

      }

      should output
      url is invalid
      url is valid

      rather produces
      url is invalid
      url is invalid

      Attachments

        Activity

          People

            Unassigned Unassigned
            walter@easypeas.net Walter Gildersleeve
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: