Class RegexpURLValidator
java.lang.Object
org.hibernate.validator.constraintvalidators.RegexpURLValidator
- All Implemented Interfaces:
ConstraintValidator<URL,CharSequence>
Validate that the character sequence (e.g. string) is a valid URL using a regular expression.
- Since:
- 5.2
- Author:
- Hardy Ferentschik
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidinitialize(URL url) Initializes the validator in preparation forConstraintValidator.isValid(Object, ConstraintValidatorContext)calls.booleanisValid(CharSequence value, ConstraintValidatorContext constraintValidatorContext) Implements the validation logic.
-
Constructor Details
-
RegexpURLValidator
public RegexpURLValidator()
-
-
Method Details
-
initialize
Description copied from interface:ConstraintValidatorInitializes the validator in preparation forConstraintValidator.isValid(Object, ConstraintValidatorContext)calls. The constraint annotation for a given constraint declaration is passed.This method is guaranteed to be called before any use of this instance for validation.
The default implementation is a no-op.
- Specified by:
initializein interfaceConstraintValidator<URL,CharSequence> - Parameters:
url- annotation instance for a given constraint declaration
-
isValid
Description copied from interface:ConstraintValidatorImplements the validation logic. The state ofvaluemust not be altered.This method can be accessed concurrently, thread-safety must be ensured by the implementation.
- Specified by:
isValidin interfaceConstraintValidator<URL,CharSequence> - Parameters:
value- object to validateconstraintValidatorContext- context in which the constraint is evaluated- Returns:
falseifvaluedoes not pass the constraint
-