Interface Validatable

All Known Implementing Classes:
Book, JSONBase, Model, ModelRegistry, ValidationSupport

public interface Validatable
Top interface to make something validatable.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFailedValidator​(Validator validator, String errorKey)
    This method is not to add validators for future processing.
    Provides an instance of localized Errors object, filled with error messages after validation.
    errors​(Locale locale)
    Provides an instance of localized Errors object, filled with error messages after validation.
    get​(String attribute)
    Used by validators to get values
    boolean
    Implementation should call {#link validate()} internally.
    void
    Runs validation.
    void
    validate​(boolean reset)
    Runs validation.
  • Method Details

    • get

      Object get(String attribute)
      Used by validators to get values
      Parameters:
      attribute - name of attribute
      Returns:
      value of attribute
    • addFailedValidator

      void addFailedValidator(Validator validator, String errorKey)
      This method is not to add validators for future processing. This is instead used to add validators and their respective error messages in case those validators fail.
      Parameters:
      validator - validator that failed validation (later to be used to retrieve error message)
      errorKey - - generally an attribute name that failed validation
    • isValid

      boolean isValid()
      Implementation should call {#link validate()} internally.
      Returns:
      true if object is valid.
    • validate

      void validate()
      Runs validation. Will blow away any previous validation errors.
    • validate

      void validate(boolean reset)
      Runs validation.
      Parameters:
      reset - true to reset all previous validation errors.
    • errors

      Errors errors()
      Provides an instance of localized Errors object, filled with error messages after validation.
      Returns:
      an instance of localized Errors object, filled with error messages after validation.
    • errors

      Errors errors(Locale locale)
      Provides an instance of localized Errors object, filled with error messages after validation.
      Parameters:
      locale - locale to pick the right resource bundle.
      Returns:
      an instance of localized Errors object, filled with error messages after validation.