Uploaded image for project: 'JSPWiki'
  1. JSPWiki
  2. JSPWIKI-864

ValidationManager added to WikiEngine

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • None
    • None
    • Core & storage
    • None

    Description

      Here is another idea. When I write plugins, I spend a lot of time writing code to make sure that the parameters passed into the plugins are valid. Things such as strings, booleans, numbers, urls, emails addresses, etc.

      I was thinking if we could create a ValidationManager class that could take a List of "Validators (interface)" and pass values for validation.

      The two main interface method of a Validator would be:

      • void validate(String value, String type) throws InvalidValueException;
      • void validate(String value, String type, boolean required) throws InvalidValueException;
        • Note: by default "required" would be false.

      The type would be a static int TYPE_EMAIL, TYPE_STRING, etc. defined in the ValidationManager.

      The ValidationManager, would have property:

      • List<Validator> validators;
        and methods:
      • void addValidator(Validator v);
      • Validator removeValidator(Validator v);
      • List <Validator> getValidators();

      This would be very beneficial for all plugin developers, cause then they can call:

      • wikiContent.getValidationManager().validate(params.get('url'),ValidationManager.TYPE_URL);

      And they don't need a try catch, as the user will be told exactly what the error was. If all parameters are valid, the plugin can continue to do it's work.

      Attachments

        Activity

          People

            Unassigned Unassigned
            dvittor David Vittor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: