Class RegExValidator
- java.lang.Object
-
- org.sourceid.saml20.adapter.gui.validation.impl.RegExValidator
-
- All Implemented Interfaces:
Serializable,FieldValidator
- Direct Known Subclasses:
EmailValidator
public class RegExValidator extends Object implements FieldValidator
Validates a field values based on a regular expression.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_MESSAGE_FORMAT
-
Constructor Summary
Constructors Constructor Description RegExValidator(String regex)Build a validator by compiling the provided regex.RegExValidator(String regex, int flags)Build a validator by compiling the provided regex and associated flags.RegExValidator(Pattern pattern)Build a validator with the provided pattern.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetMessageFormat(String messagePattern)Set the message formatter pattern to be used for validation error message.voidvalidate(Field field)Validates the field value is properly formatted.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.sourceid.saml20.adapter.gui.validation.FieldValidator
isExternalValidator
-
-
-
-
Field Detail
-
DEFAULT_MESSAGE_FORMAT
public static final String DEFAULT_MESSAGE_FORMAT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RegExValidator
public RegExValidator(Pattern pattern)
Build a validator with the provided pattern.- Parameters:
pattern- Regex pattern.
-
RegExValidator
public RegExValidator(String regex)
Build a validator by compiling the provided regex.- Parameters:
regex- String representation of the regex.- See Also:
Pattern.compile(String)
-
RegExValidator
public RegExValidator(String regex, int flags)
Build a validator by compiling the provided regex and associated flags.- Parameters:
regex- String representation of the regex.flags- Regex matching flags.- See Also:
Pattern.compile(String, int)
-
-
Method Detail
-
setMessageFormat
public void setMessageFormat(String messagePattern)
Set the message formatter pattern to be used for validation error message. If not set, a default, generic, message format will be used.When formatting a message two arguments will be passed, the field name and the field value.
- Parameters:
messagePattern- The actual message formatter patter. {0} is the field name and {1} is the field value.- See Also:
MessageFormat
-
validate
public void validate(Field field) throws ValidationException
Validates the field value is properly formatted.- Specified by:
validatein interfaceFieldValidator- Parameters:
field- The field to be validate.- Throws:
ValidationException- If the field value is not formatted correctly.
-
-