Aerostack
bar_chart

data-json-schema-validate Edge Function — Data

Data

Validates any JavaScript value against a JSON Schema Draft 7 schema with zero external dependencies.

navin @navin verified
Updated Mar 12, 2026
GitHub

Edge function data-json-schema-validate Validates any JavaScript value against a JSON Schema Draft 7 schema with zero external dependencies.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.

terminal — aerostack cli
$ npx aerostack add navin/data-json-schema-validate
smart_toy

Use with AI Assistants

MCP

Connect Claude, Cursor, or any MCP-compatible client — then call this function by slug

① Add MCP Server

Add this once — access all Aerostack functions from your AI tool.

claude_desktop_config.json
{
  "mcpServers": {
    "aerostack": {
      "url": "https://mcp.aerostack.dev",
      "type": "http"
    }
  }
}

② Call this function

Ask your AI to use the call_function tool with this slug:

call_function
call_function({
  slug: "data-json-schema-validate",
  args: {
    "schema": null,
    "data": null
  }
})

data-json-schema-validate — JSON Schema Draft 7 validator

Validates any value against a JSON Schema Draft 7 schema with zero external dependencies.


API

POST /api/data-json-schema-validate

Request body

Field Type Required Description
schema object JSON Schema Draft 7 object
data any Value to validate

Supported keywords: type, required, properties, minimum, maximum, minLength, maxLength, pattern, enum, items, additionalProperties

Success response (200)

{
  "success": true,
  "data": {
    "valid": false,
    "errors": [
      { "path": "age", "message": "Value 200 is greater than maximum 150" }
    ]
  }
}

Error responses

Code HTTP When
INVALID_INPUT 400 Missing schema or data field
INTERNAL_ERROR 500 Unexpected error

Usage

cURL
curl -X POST "$FUNCTION_URL" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {"type":"object","required":["name"],"properties":{"name":{"type":"string"}}},
    "data": {"name": "Alice"}
  }'
TypeScript / JavaScript (HTTP)
const response = await fetch(FUNCTION_URL, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ schema: mySchema, data: userInput }),
});
const { data } = await response.json();
if (!data.valid) console.error(data.errors);
Direct import (Node / Bun / Deno)
import { jsonSchemaValidate } from '@aerostack/functions/data-json-schema-validate';

const result = jsonSchemaValidate({ schema: mySchema, data: userInput });
if (!result.valid) throw new Error(result.errors[0]?.message);

Use Cases

  • Validating API request bodies against a predefined schema before processing
  • Checking user-submitted form data or config objects for correctness
  • Validating webhook payloads from third-party services before ingesting into a database

Notes

  • Implements JSON Schema Draft 7 subset: type, required, properties, minimum, maximum, minLength, maxLength, pattern, enum, items, additionalProperties
  • Zero external dependencies — safe to use in Cloudflare Workers
  • Errors include a path field using dot and bracket notation (e.g. user.address[0].zip)

Metadata

upgrade Version 1.0.0
gavel License MIT
language Language typescript
cloud Provider aerostack

Tags

data
deployed_code

Build and publish your own functions

Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.

More Data Functions

Browse Data Functions →

Frequently asked questions

What does the data-json-schema-validate function do? +

data-json-schema-validate is a serverless edge function for data automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.

How do I deploy the data-json-schema-validate function? +

Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/data-json-schema-validate ``` It will be live on Cloudflare Workers in seconds.

What runtime does data-json-schema-validate use? +

data-json-schema-validate runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.

Can I customise the data-json-schema-validate function? +

Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.