Interface Validator

All Known Implementing Classes:
CompoundValidator
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Validator
An interface that is used to validate text input
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A functional interface that is used to check if a string is valid
  • Method Summary

    Modifier and Type
    Method
    Description
    default Validator
    and(Validator other)
    Combines two validators into one, that ensures that both output true
    default Validator
    Combines this validator with a new regex-based validator
    default Validator
    Combines this validator with a new regex-based validator
    boolean
    isValid(String input)
    Ensures that input is valid
    static @NotNull Validator
    Constructs a validator that matches based on a Regular Expression
    static @NotNull Validator
    matching(Pattern compiled)
    Constructs a validator that matches based on a compiled Regular Expression
    static @NotNull Validator
    of(@NotNull Validator.Checker checker)
    Constructs a validator based on a manual checker
  • Method Details

    • matching

      @Contract("_ -> new") @NotNull static @NotNull Validator matching(@Language("RegExp") @RegEx String regex)
      Constructs a validator that matches based on a Regular Expression
      Parameters:
      regex - Regex to match against
      Returns:
      A new validator that matches based on the regex
    • matching

      @Contract("_ -> new") @NotNull static @NotNull Validator matching(Pattern compiled)
      Constructs a validator that matches based on a compiled Regular Expression
      Parameters:
      compiled - Compiled regex to match against
      Returns:
      A new validator that matches based on the regex
    • of

      @NotNull static @NotNull Validator of(@NotNull @NotNull Validator.Checker checker)
      Constructs a validator based on a manual checker
      Parameters:
      checker - Lambda checker to use
      Returns:
      A new validator
    • isValid

      boolean isValid(String input)
      Ensures that input is valid
      Parameters:
      input - Input to be checked
      Returns:
      True if input is valid, false otherwise
    • and

      default Validator and(Validator other)
      Combines two validators into one, that ensures that both output true
      Parameters:
      other - Other validator to be added
      Returns:
      A new compound validator
    • andMatching

      default Validator andMatching(@RegEx @Language("RegExp") String regex)
      Combines this validator with a new regex-based validator
      Parameters:
      regex - Regex for new validator to match against
      Returns:
      A new compound validator
    • andMatching

      default Validator andMatching(Pattern pattern)
      Combines this validator with a new regex-based validator
      Parameters:
      pattern - Compiled regex for new validator to match against
      Returns:
      A new compound validator