Class TextValidationRules

java.lang.Object
org.strassburger.tui4j.input.validationrules.TextValidationRules

public class TextValidationRules extends Object
  • Constructor Details

    • TextValidationRules

      public TextValidationRules()
  • Method Details

    • noSpaces

      public static ValidationRule<String> noSpaces()
      Returns a validation rule that checks if the input contains spaces.
      Returns:
      A validation rule that checks if the input contains spaces.
    • noSpaces

      public static ValidationRule<String> noSpaces(String errorMessage)
      Returns a validation rule that checks if the input contains spaces with a custom error message.
      Parameters:
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input contains spaces.
    • noSpaces

      public static ValidationRule<String> noSpaces(StyledText errorMessage)
      Returns a validation rule that checks if the input contains spaces with a custom error message.
      Parameters:
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input contains spaces.
    • minLength

      public static ValidationRule<String> minLength(int length)
      Returns a validation rule that checks if the input is at least a certain length.
      Parameters:
      length - The minimum length of the input.
      Returns:
      A validation rule that checks if the input is at least a certain length.
    • minLength

      public static ValidationRule<String> minLength(int length, String errorMessage)
      Returns a validation rule that checks if the input is at least a certain length with a custom string error message.
      Parameters:
      length - The minimum length of the input.
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input is at least a certain length.
    • minLength

      public static ValidationRule<String> minLength(int length, StyledText errorMessage)
      Returns a validation rule that checks if the input is at least a certain length with a custom error message.
      Parameters:
      length - The minimum length of the input.
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input is at least a certain length.
    • maxLength

      public static ValidationRule<String> maxLength(int length)
      Returns a validation rule that checks if the input is at most a certain length.
      Parameters:
      length - The maximum length of the input.
      Returns:
      A validation rule that checks if the input is at most a certain length.
    • maxLength

      public static ValidationRule<String> maxLength(int length, String errorMessage)
      Returns a validation rule that checks if the input is at most a certain length with a custom string error message.
      Parameters:
      length - The maximum length of the input.
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input is at most a certain length.
    • maxLength

      public static ValidationRule<String> maxLength(int length, StyledText errorMessage)
      Returns a validation rule that checks if the input is at most a certain length with a custom error message.
      Parameters:
      length - The maximum length of the input.
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input is at most a certain length.
    • disallowEmpty

      public static ValidationRule<String> disallowEmpty()
      Returns a validation rule that checks if the input is not empty.
      Returns:
      A validation rule that checks if the input is not empty.
    • disallowEmpty

      public static ValidationRule<String> disallowEmpty(String errorMessage)
      Returns a validation rule that checks if the input is not empty with a custom string error message.
      Parameters:
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input is not empty.
    • disallowEmpty

      public static ValidationRule<String> disallowEmpty(StyledText errorMessage)
      Returns a validation rule that checks if the input is not empty with a custom error message.
      Parameters:
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input is not empty.
    • regex

      public static ValidationRule<String> regex(String regex)
      Returns a validation rule that checks if the input matches a certain regex.
      Parameters:
      regex - The regex to match.
      Returns:
      A validation rule that checks if the input matches a certain regex.
    • regex

      public static ValidationRule<String> regex(String regex, String errorMessage)
      Returns a validation rule that checks if the input matches a certain regex with a custom string error message.
      Parameters:
      regex - The regex to match.
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input matches a certain regex.
    • regex

      public static ValidationRule<String> regex(String regex, StyledText errorMessage)
      Returns a validation rule that checks if the input matches a certain regex with a custom error message.
      Parameters:
      regex - The regex to match.
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input matches a certain regex.
    • noNumbers

      public static ValidationRule<String> noNumbers()
      Returns a validation rule that checks if the input does not contain numbers.
      Returns:
      A validation rule that checks if the input does not contain numbers.
    • noNumbers

      public static ValidationRule<String> noNumbers(String errorMessage)
      Returns a validation rule that checks if the input does not contain numbers with a custom string error message.
      Parameters:
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input does not contain numbers.
    • noNumbers

      public static ValidationRule<String> noNumbers(StyledText errorMessage)
      Returns a validation rule that checks if the input does not contain numbers with a custom error message.
      Parameters:
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input does not contain numbers.
    • alphanumeric

      public static ValidationRule<String> alphanumeric()
      Returns a validation rule that checks if the input is alphanumeric.
      Returns:
      A validation rule that checks if the input is alphanumeric.
    • alphanumeric

      public static ValidationRule<String> alphanumeric(String errorMessage)
      Returns a validation rule that checks if the input is alphanumeric with a custom string error message.
      Parameters:
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input is alphanumeric.
    • alphanumeric

      public static ValidationRule<String> alphanumeric(StyledText errorMessage)
      Returns a validation rule that checks if the input is alphanumeric with a custom error message.
      Parameters:
      errorMessage - The custom error message.
      Returns:
      A validation rule that checks if the input is alphanumeric.