[ https://issues.apache.org/jira/browse/JSPWIKI-864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14113686#comment-14113686 ]
David Vittor commented on JSPWIKI-864: -------------------------------------- Hi Glen, Thanks for the comment, I'm definitely happy to use this framework for validation. However as my plan is to write a whole lot of different plugins, I'm wondering if we could add this validation framework to the core jspwiki-war/pom.xml file. http://mvnrepository.com/artifact/commons-validator/commons-validator/1.4.0 <dependency> <groupId>commons-validator</groupId> <artifactId>commons-validator</artifactId> <version>1.4.0</version> </dependency> If we do that then in my individual plugins I can add the above, with scope set to "provided" which means I will assume that this is available in the platform. Let us know what you think. Cheers. > 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)