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, toResult
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
alwaysPass, from, from, from, from
andThen
public 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)
Validator
ValidationResult
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 © 2025. All rights reserved.