Lacritz / spring-config-validation

Wrapper around the spring-config domaine. As one may not run validation on a specific property set without bothering the actual application, I like to introduce my custom way to tackle this issue.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Configuration Validation

This project is a wrapper around the spring configuration mechanism and adds feature such as dry-run validation and exposing the configuration properties via REST.

Installation

How to Use

Access Configuration

Configuration IDs are accessible using GET /rest/v1/config.
Example:

[
  "com.lacritz.example.postgres",
  "com.lacritz.example.mysql",
  "com.lacritz.example.application"
]

Configurations are accessible using GET /rest/v1/config/{id}
Example:

{
  "id": "com.lacritz.example.postgres",
  "group": "Database",
  "properties": [
    {
      "name": "com.lacritz.example.postgres.url",
      "type": "URL" 
    },
    {
      "name": "com.lacritz.example.postgres.user",
      "type": "string"
    },
    {
      "name": "com.lacritz.example.postgres.password",
      "type": "char[]"
    }
  ]
}

Validation

Validation for a specific configuration can be triggered using POST /rest/v1/config/{id}/validate.
The properties must be sent as part of the body.
Example (*.json):

[
  {"com.lacritz.example.postgres.url": "http://localhost:5432"},
  {"com.lacritz.example.postgres.user": "lacritz"},
  {"com.lacritz.example.postgres.password": "secret"}
]

Example (*.properties)

com.lacritz.example.postgres.url: "http://localhost:5432"
com.lacritz.example.postgres.user: "lacritz"
com.lacritz.example.postgres.secret: "secret"

The server will respond with a validation result.
Example:

{
  "id": "com.lacritz.example.postgres",
  "group": "Database",
  "properties": [
    {
      "name": "com.lacritz.example.postgres.url",
      "status": true
    },
    {
      "name": "com.lacritz.example.postgres.user",
      "valid": false,
      "reason": "The user must not be empty."
    },
    {
      "name": "com.lacritz.example.postgres.password",
      "valid": true
    }
  ]
}

About

Wrapper around the spring-config domaine. As one may not run validation on a specific property set without bothering the actual application, I like to introduce my custom way to tackle this issue.