Class SetValidator

  • All Implemented Interfaces:
    IValidator, Serializable

    public class SetValidator
    extends Object
    implements IValidator
    Validates if given value is in the set. This class implements IValidator interface. Default constructor should be used to create this object. Pass the string value to be validated and set of Stringvalues against which the value should be validated to validate function, true is returned if the value is present in the set.
    See Also:
    Serialized Form
    • Constructor Detail

      • SetValidator

        public SetValidator()
    • Method Detail

      • validate

        public boolean validate​(String value,
                                String set)
        Checks if the value is in the set. Validates the string value against the rule, which is a set of elements in the form of a String, with each elements separated by comma.
         Example: validate("A", "A,B,C,D,F"); // returns true
         validate("408", "415,650,408,510"); // returns true
         validate("770", "415,650,408,510"); // returns false
         validate(408, "415,650,408,510"); // exception
         
        Specified by:
        validate in interface IValidator
        Parameters:
        value - Value to validate.
        set - Set used by the validation, in the form of a String with each elements separated by comma.
        Returns:
        true if value is in the set