com.vaadin.data.validator.

Class StringLengthValidator

    • Constructor Detail

      • StringLengthValidator

        public StringLengthValidator​(String errorMessage,
                                     Integer minLength,
                                     Integer maxLength)

        Creates a new StringLengthValidator with a given error message and minimum and maximum length limits.

        Parameters:

        errorMessage - the error message to return if validation fails

        minLength - 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.

    • Method Detail

      • apply

        public ValidationResult apply​(String value,
                                      ValueContext context)

        Description copied from interface: Validator

        Validates the given value. Returns a ValidationResult instance representing the outcome of the validation.

        Parameters:

        value - the input value to validate

        context - the value context for validation

        Returns:

        the validation result

      • getMaxLength

        public Integer getMaxLength()

        Gets the maximum permissible length of the string.

        Returns:

        the maximum length of the string or null if there is no limit

      • getMinLength

        public Integer getMinLength()

        Gets the minimum permissible length of the string.

        Returns:

        the minimum length of the string or null if there is no limit

      • setMaxLength

        public void setMaxLength​(Integer maxLength)

        Sets the maximum permissible length of the string.

        Parameters:

        maxLength - the maximum length to accept or null for no limit

      • setMinLength

        public void setMinLength​(Integer minLength)

        Sets the minimum permissible length.

        Parameters:

        minLength - the minimum length to accept or null for no limit