mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Extends annotation to support new URL regex parameters
This commit is contained in:
+6
@@ -528,6 +528,12 @@ public class AnnotationValidationConfigurationBuilder {
|
||||
} else if (v.fieldName() != null && v.fieldName().length() > 0) {
|
||||
params.put("fieldName", v.fieldName());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(v.urlRegex())) {
|
||||
params.put("urlRegex", v.urlRegex());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(v.urlRegexExpression())) {
|
||||
params.put("urlRegexExpression", v.urlRegexExpression());
|
||||
}
|
||||
|
||||
validatorFactory.lookupRegisteredValidatorType(validatorType);
|
||||
return new ValidatorConfig.Builder(validatorType)
|
||||
|
||||
+10
-64
@@ -22,75 +22,12 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
* This validator checks that a field is a valid URL.
|
||||
* <!-- END SNIPPET: description -->
|
||||
*
|
||||
* <p/> <u>Annotation usage:</u>
|
||||
*
|
||||
* <!-- START SNIPPET: usage -->
|
||||
* <p/>The annotation must be applied at method level.
|
||||
* <!-- END SNIPPET: usage -->
|
||||
*
|
||||
* <p/> <u>Annotation parameters:</u>
|
||||
*
|
||||
* <!-- START SNIPPET: parameters -->
|
||||
* <table class='confluenceTable'>
|
||||
* <tr>
|
||||
* <th class='confluenceTh'> Parameter </th>
|
||||
* <th class='confluenceTh'> Required </th>
|
||||
* <th class='confluenceTh'> Default </th>
|
||||
* <th class='confluenceTh'> Notes </th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td class='confluenceTd'>message</td>
|
||||
* <td class='confluenceTd'>yes</td>
|
||||
* <td class='confluenceTd'> </td>
|
||||
* <td class='confluenceTd'>field error message</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td class='confluenceTd'>key</td>
|
||||
* <td class='confluenceTd'>no</td>
|
||||
* <td class='confluenceTd'> </td>
|
||||
* <td class='confluenceTd'>i18n key from language specific properties file.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td class='confluenceTd'>messageParams</td>
|
||||
* <td class='confluenceTd'>no</td>
|
||||
* <td class='confluenceTd'> </td>
|
||||
* <td class='confluenceTd'>Additional params to be used to customize message - will be evaluated against the Value Stack</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td class='confluenceTd'>fieldName</td>
|
||||
* <td class='confluenceTd'>no</td>
|
||||
* <td class='confluenceTd'> </td>
|
||||
* <td class='confluenceTd'> </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td class='confluenceTd'>shortCircuit</td>
|
||||
* <td class='confluenceTd'>no</td>
|
||||
* <td class='confluenceTd'>false</td>
|
||||
* <td class='confluenceTd'>If this validator should be used as shortCircuit.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td class='confluenceTd'>type</td>
|
||||
* <td class='confluenceTd'>yes</td>
|
||||
* <td class='confluenceTd'>ValidatorType.FIELD</td>
|
||||
* <td class='confluenceTd'>Enum value from ValidatorType. Either FIELD or SIMPLE can be used here.</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* <!-- END SNIPPET: parameters -->
|
||||
*
|
||||
* <p/> <u>Example code:</u>
|
||||
*
|
||||
* <pre>
|
||||
* <!-- START SNIPPET: example -->
|
||||
* @UrlValidator(message = "Default message", key = "i18n.key", shortCircuit = true)
|
||||
* <!-- END SNIPPET: example -->
|
||||
* </pre>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@@ -121,7 +58,6 @@ public @interface UrlValidator {
|
||||
* If this is activated, the validator will be used as short-circuit.
|
||||
*
|
||||
* Adds the short-circuit="true" attribute value if <tt>true</tt>.
|
||||
*
|
||||
*/
|
||||
boolean shortCircuit() default false;
|
||||
|
||||
@@ -130,4 +66,14 @@ public @interface UrlValidator {
|
||||
*/
|
||||
ValidatorType type() default ValidatorType.FIELD;
|
||||
|
||||
/**
|
||||
* Defines regex to use to validate url
|
||||
*/
|
||||
String urlRegex() default "";
|
||||
|
||||
/**
|
||||
* Defines regex as an expression which will be evaluated to string and used to validate url
|
||||
*/
|
||||
String urlRegexExpression() default "";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user