java.lang.Object
com.dlsc.formsfx.model.validators.CustomValidator<String>
com.dlsc.formsfx.model.validators.StringLengthValidator
public class StringLengthValidator extends CustomValidator<String>
A StringLengthValidator checks if a string value's length is between a
minimum and a maximum value.
- Author:
- Sacha Schmid, Rinesch Murugathas
-
Method Summary
Modifier and Type Method Description static StringLengthValidatoratLeast(int min, String errorMessage)Creates an StringLengthValidator with a given lower bound.static StringLengthValidatorbetween(int min, int max, String errorMessage)Creates an StringLengthValidator with given lower and upper bounds.protected ValidationResultcreateResult(boolean result)Creates aValidationResultbased on the validation result.static StringLengthValidatorexactly(int value, String errorMessage)Creates a StringLengthValidator with a given lower and upper bound, which are equal.static StringLengthValidatorupTo(int max, String errorMessage)Creates an StringLengthValidator with a given upper bound.Methods inherited from class com.dlsc.formsfx.model.validators.CustomValidator
forPredicate, validate
-
Method Details
-
between
Creates an StringLengthValidator with given lower and upper bounds.- Parameters:
min- The lower bound for the validation.max- The upper bound for the validation.errorMessage- The error message that is returned if the validation fails.- Returns:
- Returns a new StringLengthValidator.
- Throws:
IllegalArgumentException- Thrown if the minimum is a negative number.
-
atLeast
Creates an StringLengthValidator with a given lower bound.- Parameters:
min- The lower bound for the validation.errorMessage- The error message that is returned if the validation fails.- Returns:
- Returns a new StringLengthValidator.
- Throws:
IllegalArgumentException- Thrown if the minimum is a negative number.
-
upTo
Creates an StringLengthValidator with a given upper bound.- Parameters:
max- The upper bound for the validation.errorMessage- The error message that is returned if the validation fails.- Returns:
- Returns a new StringLengthValidator.
-
exactly
Creates a StringLengthValidator with a given lower and upper bound, which are equal.- Parameters:
value- The lower and upper bound for the validation.errorMessage- The error message that is returned if the validation fails.- Returns:
- Returns a new StringLengthValidator.
-
createResult
Creates aValidationResultbased on the validation result.- Parameters:
result- The result of the validation.- Returns:
- Returns a new ValidationResult containing result and message.
-