/valex

Produce predictable and consumable REST error payloads with Valex, a YAML-based validation and exception management library for Java.

Primary LanguageJavaApache License 2.0Apache-2.0

Build Status Coverage Status codebeat badge

Introduction

An API should provide useful error responses in a predictable and consumable format. An error response should provide a few things for a developer - a useful error message, a unique error code, and a meaningful HTTP response code.

Valex can help you produce meaningful responses that include an appropriate HTTP response code as well as a JSON payload that looks like this:

{
  "errors": [
    {
      "code": "ACC-1000",
      "message": "An account username is required."
    },
    {
      "code": "ADD-1001",
      "message": "An account password is required."
    }
  ]
}

The JSON payload is entirely configuration driven, so you can produce a JSON payload that looks like this just as easily:

{
  "errors": [
    {
      "code": "ACC-1000",
      "message": "An account username is required.",
      "field": "account.username",
      "support_url": "https://support.yoursite.com/kb/articles/acc-1000.html"
    },
    {
      "code": "ADD-1001",
      "message": "An account password is required.",
      "field": "account.password",
      "support_url": "https://support.yoursite.com/kb/articles/add-1001.html"
    }
  ]
}

Quick Start Guide & Documentation

A quick start guide and reference documentation for Valex is hosted on the Valex Project Page.

Building from Source

Both JDK 8 and Maven 3 are required to build Valex from source. With these prerequisites in place you can build Valex by:

git clone https://github.com/PatternFM/valex.git
cd valex
mvn clean install

Continuous Integration

The Continuous Integration service for the project is hosted on Travis

Licensing

This software is provided and distributed under the Apache Software License 2.0. Refer to LICENSE.txt for more information.