data-json-schema-validate Edge Function — Data
DataValidates any JavaScript value against a JSON Schema Draft 7 schema with zero external dependencies.
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.
npx aerostack add navin/data-json-schema-validate Use with AI Assistants
MCPConnect 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.
{
"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({
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
pathfield using dot and bracket notation (e.g.user.address[0].zip)
Metadata
Tags
Publisher
@navin verified
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 →data-aggregate-stats
by @navin
Computes descriptive statistics (count, sum, min, max, mean, median, stdDev, variance, percentiles) for an array of numbers.
data-array-group-by
by @navin
Groups an array of objects into a map keyed by the value of a specified property. Zero dependencies.
data-csv-parse
by @navin
Parses a CSV string into an array of row objects with headers, handling quoted fields, custom delimiters, and escaped characters.
data-csv-to-json
by @navin
Converts a CSV string to a typed JSON array, automatically inferring numbers, booleans, and null values from string fields.
data-deep-diff
by @navin
Computes a structural deep diff between two JSON-serializable values, classifying each change as added, removed, or modified.
data-sort-objects
by @navin
Sorts an array of objects by one or more fields with configurable direction, null handling, and nested field dot-notation support.
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.