Skip to content

Validation API

Validate data against a JSON Schema without creating content.

Validate Data

Validate data against a schema.

Endpoint: POST /api/v1/validation

Request Body:

json
{
  "schema": {
    "type": "string",
    "minLength": 5
  },
  "data": "hello world"
}

Example Request:

bash
curl -X POST "https://access.flatnode.io/api/v1/validation" \
  -H "Authorization: Bearer your-token-here" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "type": "string",
      "minLength": 5
    },
    "data": "hello world"
  }'

Response: 200 OK (if valid)

json
{
  "valid": true,
  "errors": []
}

Response: 422 Unprocessable Entity (if invalid)

json
{
  "valid": false,
  "errors": [
    {
      "field": "data",
      "message": "String is shorter than the minimum allowed length (5)"
    }
  ]
}

Validation Use Cases

Use the validation endpoint to:

  • Test data before creating content
  • Validate user input in frontend applications
  • Check schema compatibility
  • Debug validation issues

Example: Validating Array Data

bash
curl -X POST "https://access.flatnode.io/api/v1/validation" \
  -H "Authorization: Bearer your-token-here" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "type": "array",
      "minItems": 2,
      "maxItems": 3,
      "items": {
        "type": "integer"
      }
    },
    "data": [1, 2, 3]
  }'

Example: Validating Object Data

bash
curl -X POST "https://access.flatnode.io/api/v1/validation" \
  -H "Authorization: Bearer your-token-here" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "type": "object",
      "required": ["firstName"],
      "properties": {
        "firstName": {
          "type": "string"
        },
        "helpText": {
          "type": "null"
        }
      }
    },
    "data": {
      "firstName": "Chuck",
      "helpText": null
    }
  }'