Interface MinMaxLengthElement

    • Method Detail

      • validateMinAndMaxLengths

        default void validateMinAndMaxLengths()
                                       throws InvalidInputException
        This method checks if the values assigned to minlength and maxlength attributes are valid. If there is an initial value in the textarea it also checks if the latter is between the range given
        Throws:
        InvalidInputException - when the attributes value are not valid or the input is not in range
      • validateInitialValueIfFound

        default void validateInitialValueIfFound​(Integer minLength,
                                                 Integer maxLength)
                                          throws InvalidInputException
        This method validates in case there is an initial value in the element, if that input is a valid one, meaning that it respects the range of minlength and maxlength.
        Parameters:
        minLength - value
        maxLength - value
        Throws:
        InvalidInputException - if the the initial value is not in range
      • getDefaultValueIfCurrentIsNull

        default Integer getDefaultValueIfCurrentIsNull​(Integer currentValue,
                                                       Integer defaultValue)
        In case these is no maxlenght or no minlength this method return the default value assigned to each attributes
        Parameters:
        currentValue - is attribute as a value assigned
        defaultValue - default value for that attribute
        Returns:
      • isMinAndMaxLengthCombinationValid

        default boolean isMinAndMaxLengthCombinationValid​(Integer minLength,
                                                          Integer maxLength)
        Checks if the [minlength, maxlength] range is valid
        Parameters:
        maxLength - value
        minLength - value
        Returns:
        true is the range is valid
      • isTextBiggerThanMaxLength

        default boolean isTextBiggerThanMaxLength​(Integer maxLength,
                                                  String text)
        Parameters:
        maxLength - value
        text - given in input
        Returns:
        true if the input is not longer that maxlength
      • isTextSmallerThanMinLength

        default boolean isTextSmallerThanMinLength​(Integer minLength,
                                                   String text)
        Parameters:
        minLength - value
        text - given in input
        Returns:
        true if the input is not smaller that maxlength
      • getAttributeAsInteger

        default Integer getAttributeAsInteger​(String attributeName)
                                       throws InvalidInputException
        This method take the value corresponding to the attribute given as input and convert it to an Integer, if possible
        Parameters:
        attributeName - attribute to be converted
        Returns:
        Integer version of the attribute
        Throws:
        InvalidInputException - if the value of the attribute is not a numeric one
      • isLengthOutOfRange

        default boolean isLengthOutOfRange​(Integer length)
        Check if the length of the input is in the default ranges of the element
        Parameters:
        length - of the input
        Returns:
      • getLengthErrorMessage

        default String getLengthErrorMessage​(String attributeName)
      • getElementType

        String getElementType()
        Returns:
        the type of the element
      • hasElementInitialValue

        boolean hasElementInitialValue()
        Returns:
        true if the element has an initial value
      • getElementInitialValue

        String getElementInitialValue()
        Returns:
        the initial value found in the element
      • getAttributeValue

        String getAttributeValue​(String attributeName)
        Parameters:
        attributeName - we want to retrieve
        Returns:
        the value corresponding to the attributeName given in input
      • getMinValueAllowed

        Integer getMinValueAllowed()
        Returns:
        minimum value allowed for the minLength attribute
      • getMaxValueAllowed

        Integer getMaxValueAllowed()
        Returns:
        maximum value allowed for the maxLength attribute