Class Violations

java.lang.Object
com.codename1.backend.validation.Violations

public final class Violations extends Object
Collects the FieldErrors of one request. The generated validation code calls it; an application has no reason to.
  • Constructor Details

    • Violations

      public Violations()
  • Method Details

    • add

      public void add(String field, String code, String message, String fallback)
      Records one failure.
      Parameters:
      field - the path
      code - the constraint's simple name
      message - the declared message, or empty for fallback
      fallback - the default message
    • errors

      public List<FieldError> errors()
      What was recorded so far.
      Returns:
      the errors, possibly empty
    • check

      public void check()
      Throws a ValidationException when anything was recorded.
    • path

      public static String path(String prefix, String name)
      prefix.name, or name at the root.
      Parameters:
      prefix - the parent path, empty at the root
      name - the property
      Returns:
      the path
    • index

      public static String index(String prefix, int index)
      prefix[index].
      Parameters:
      prefix - the collection's path
      index - the element
      Returns:
      the path
    • isBlank

      public static boolean isBlank(CharSequence s)
      Whether s is null or only whitespace.
      Parameters:
      s - the value
      Returns:
      true when blank