public class StringLengthValidator extends AbstractValidator<String>
| Constructor and Description |
|---|
StringLengthValidator(String errorMessage,
Integer minLength,
Integer maxLength)
Creates a new StringLengthValidator with a given error message and
minimum and maximum length limits.
|
| Modifier and Type | Method and Description |
|---|---|
ValidationResult |
apply(String value,
ValueContext context)
Validates the given value.
|
Integer |
getMaxLength()
Gets the maximum permissible length of the string.
|
Integer |
getMinLength()
Gets the minimum permissible length of the string.
|
void |
setMaxLength(Integer maxLength)
Sets the maximum permissible length of the string.
|
void |
setMinLength(Integer minLength)
Sets the minimum permissible length.
|
String |
toString() |
getMessage, toResultclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitalwaysPass, from, from, from, fromandThenpublic StringLengthValidator(String errorMessage, Integer minLength, Integer maxLength)
errorMessage - the error message to return if validation failsminLength - the minimum permissible length of the string or null for no
limit.maxLength - the maximum permissible length of the string or null for no
limit.public ValidationResult apply(String value, ValueContext context)
ValidatorValidationResult instance
representing the outcome of the validation.value - the input value to validatecontext - the value context for validationpublic Integer getMaxLength()
public Integer getMinLength()
public void setMaxLength(Integer maxLength)
maxLength - the maximum length to accept or null for no limitpublic void setMinLength(Integer minLength)
minLength - the minimum length to accept or null for no limitCopyright © 2020. All rights reserved.