Top Description Fields Constructors Methods
com.dlsc.formsfx.model.validators

public Class RegexValidator

extends RootValidator<String>
Class Inheritance
Imports
java.util.regex.Pattern, .PatternSyntaxException

A RegexValidator checks if a given input matches a regular expression.
Authors
Sacha Schmid, Rinesch Murugathas

Field Summary

Modifier and TypeField and Description
private Pattern

Constructor Summary

AccessConstructor and Description
private
RegexValidator(String pattern, String errorMessage)

Method Summary

Modifier and TypeMethod and Description
public static RegexValidator

Returns:

Returns a new RegexValidator.
forAlphaNumeric
(String
The error message that is returned if the validation fails.
errorMessage
)

Creates a RegexValidator for alphanumeric inputs.

public static RegexValidator

Returns:

Returns a new RegexValidator.
forEmail
(String
The error message that is returned if the validation fails.
errorMessage
)

Creates a RegexValidator for email addresses.

public static RegexValidator

Returns:

Returns a new RegexValidator.
forPattern
(String
The pattern to use for the validation. Must be a valid RegEx.
pattern
,
String
The error message that is returned if the validation fails.
errorMessage
)

Creates a RegexValidator with a custom pattern.

public static RegexValidator

Returns:

Returns a new RegexValidator.
forURL
(String
The error message that is returned if the validation fails.
errorMessage
)

Creates a RegexValidator for URLs.

public ValidationResult
Inherited from com.dlsc.formsfx.model.validators.RootValidator:
createResult

Field Detail

patternback to summary
private Pattern pattern

Constructor Detail

RegexValidatorback to summary
private RegexValidator(String pattern, String errorMessage) throws PatternSyntaxException

Method Detail

forAlphaNumericback to summary
public static RegexValidator forAlphaNumeric(String errorMessage)

Creates a RegexValidator for alphanumeric inputs.

Parameters
errorMessage:String

The error message that is returned if the validation fails.

Returns:RegexValidator

Returns a new RegexValidator.

Exceptions
PatternSyntaxException:
Thrown if the given pattern is not a valid RegEx.
forEmailback to summary
public static RegexValidator forEmail(String errorMessage)

Creates a RegexValidator for email addresses.

Parameters
errorMessage:String

The error message that is returned if the validation fails.

Returns:RegexValidator

Returns a new RegexValidator.

Exceptions
PatternSyntaxException:
Thrown if the given pattern is not a valid RegEx.
forPatternback to summary
public static RegexValidator forPattern(String pattern, String errorMessage)

Creates a RegexValidator with a custom pattern.

Parameters
pattern:String

The pattern to use for the validation. Must be a valid RegEx.

errorMessage:String

The error message that is returned if the validation fails.

Returns:RegexValidator

Returns a new RegexValidator.

Exceptions
PatternSyntaxException:
Thrown if the given pattern is not a valid RegEx.
forURLback to summary
public static RegexValidator forURL(String errorMessage)

Creates a RegexValidator for URLs.

Parameters
errorMessage:String

The error message that is returned if the validation fails.

Returns:RegexValidator

Returns a new RegexValidator.

Exceptions
PatternSyntaxException:
Thrown if the given pattern is not a valid RegEx.
validateback to summary
public ValidationResult validate(String input)

Implements com.dlsc.formsfx.model.validators.Validator.validate.

Annotations
@Override