[ https://issues.apache.org/jira/browse/JSPWIKI-864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14113619#comment-14113619 ]
Glen Mazza commented on JSPWIKI-864: ------------------------------------ Could we use this: http://commons.apache.org/proper/commons-validator/ ? I wouldn't want us to be reinventing the wheel if we can avoid it. > ValidationManager added to WikiEngine > ------------------------------------- > > Key: JSPWIKI-864 > URL: https://issues.apache.org/jira/browse/JSPWIKI-864 > Project: JSPWiki > Issue Type: Wish > Components: Core & storage > Reporter: David Vittor > Priority: Minor > > 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. -- This message was sent by Atlassian JIRA (v6.2#6252)