Class LengthValidator

java.lang.Object
jakarta.faces.validator.LengthValidator
All Implemented Interfaces:
PartialStateHolder, StateHolder, Validator, EventListener

public class LengthValidator extends Object implements Validator, PartialStateHolder

LengthValidator is a Validator that checks the number of characters in the String representation of the value of the associated component. The following algorithm is implemented:

  • Convert the passed value to a String, if necessary, by calling its toString() method.
  • If a maximum property has been configured on this Validator, check the length of the converted String against this limit. If the String length is larger than the specified maximum, throw a ValidatorException containing a a MAXIMUM_MESSAGE_ID message.
  • If a minimum property has been configured on this Validator, check the length of the converted String against this limit. If the String length is less than the specified minimum, throw a ValidatorException containing a a MINIMUM_MESSAGE_ID message.

For all of the above cases that cause a ValidatorException to be thrown, if there are parameters to the message that match up with validator parameters, the values of these parameters must be converted using the Converter registered in the application under the converter id jakarta.faces.Number. This allows the values to be localized according to the current Locale.