Class ValidationException

All Implemented Interfaces:
Serializable

public class ValidationException extends BadRequestException
Errors in schema validation.

Validation errors are usually generated based in ValidationResult. If using strict mode, warnings will also raise validation exceptions.

See Also:
  • Constructor Details

    • ValidationException

      public ValidationException(String correlationId, List<ValidationResult> results)
      Creates a new instance of validation exception and assigns its values.
      Parameters:
      correlationId - (optional) a unique transaction id to trace execution through call chain.
      results - (optional) a list of validation results
      See Also:
    • ValidationException

      public ValidationException(String correlationId, String message)
      Creates a new instance of validation exception and assigns its values.
      Parameters:
      correlationId - (optional) a unique transaction id to trace execution through call chain.
      message - (optional) a human-readable description of the error.
      See Also:
  • Method Details

    • composeMessage

      public static String composeMessage(List<ValidationResult> results)
      Composes human readable error message based on validation results.
      Parameters:
      results - a list of validation results.
      Returns:
      a composed error message.
      See Also:
    • fromResults

      public static ValidationException fromResults(String correlationId, List<ValidationResult> results, boolean strict) throws ValidationException
      Creates a new ValidationException based on errors in validation results. If validation results have no errors, than null is returned.
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      results - list of validation results that may contain errors
      strict - true to treat warnings as errors.
      Returns:
      a newly created ValidationException or null if no errors in found.
      Throws:
      ValidationException - when errors occured in validation.
      See Also:
    • throwExceptionIfNeeded

      public static void throwExceptionIfNeeded(String correlationId, List<ValidationResult> results, boolean strict) throws ValidationException
      Throws ValidationException based on errors in validation results. If validation results have no errors, than no exception is thrown.
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      results - list of validation results that may contain errors
      strict - true to treat warnings as errors.
      Throws:
      ValidationException - when errors occured in validation.
      See Also: