Class RegexValidator
java.lang.Object
org.apache.sling.validation.impl.validators.RegexValidator
Performs regular expressions validation on the supplied data with the help of the
Pattern class. This Validator expects a
mandatory parameter in the arguments map: REGEX_PARAM.-
Field Summary
FieldsFields inherited from interface org.apache.sling.validation.spi.Validator
PROPERTY_VALIDATOR_ID, PROPERTY_VALIDATOR_SEVERITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvalidate(String data, ValidatorContext context, ValueMap arguments) Validates thedataand/or thevalueMapaccording to the internal constraints of this validator.
-
Field Details
-
I18N_KEY_PATTERN_DOES_NOT_MATCH
- See Also:
-
REGEX_PARAM
- See Also:
-
-
Constructor Details
-
RegexValidator
public RegexValidator()
-
-
Method Details
-
validate
@Nonnull public ValidationResult validate(@Nonnull String data, @Nonnull ValidatorContext context, @Nonnull ValueMap arguments) throws SlingValidationException Description copied from interface:ValidatorValidates thedataand/or thevalueMapaccording to the internal constraints of this validator. The validator can enforce the type of the given data just by setting the appropriate parameter typeTwhich can be any non-primitive class. Depending on whether this type is an array or not thevalidatemethod is called differently:
If the data cannot be converted into the typeT is array type Valuemap contains array value validateis called...yes yes once per property with datacontaining the full arrayyes no once per property with datacontaining a single element arrayno yes once per element in the property array with datacontaining one array elementno no once per property with datacontaining the value of the propertyTthe validator is not called, but validation fails.- Specified by:
validatein interfaceValidator<String>- Parameters:
data- the data to validate (primary property), nevernull.context- the validation context contains additional information about the data to be validated, nevernull.arguments- the parameterization of the validator. Nevernullbut might be the empty map.- Returns:
- the validation result (encapsulates the validation status as well as messages).
- Throws:
SlingValidationException- if some expected arguments are missing from the arguments map
-