Skip to content

The code validation endpoints provide static and structural checks for JavaScript and TypeScript source code before execution. Use them to verify syntax, transpile TypeScript, inspect declared dependencies, parse magic comments, confirm a value matches a return type, or run the full validation pipeline in a single request.

All endpoints accept a JSON request body and return JSON responses. They share the same error envelope (error, code, timestamp, optional details) for non-success statuses.


Run the full validation pipeline (syntax, TypeScript, dependencies, magic comments, and source normalization) against a script in one call.

This endpoint takes no parameters.

NameTypeRequiredDescription
codestringYesSource code to validate
{
"valid": true,
"results": {
"syntax": {
"valid": true,
"message": "JavaScript syntax is valid"
},
"typescript": {
"valid": true,
"transpiledLength": 412
},
"dependencies": {
"total": 3,
"installed": 3,
"missing": 0,
"missingModules": [],
"allInstalled": true
},
"magicComments": {
"returns": "{ status: number, body: string }"
},
"normalized": false,
"transformations": []
},
"message": "Script validated successfully"
}
const result = await client.exec.validate.validateScript({
code: "export default async function() { return { status: 200, body: 'ok' }; }"
});

Validate the JavaScript syntax of a source string and report normalization transformations that were applied.

This endpoint takes no parameters.

NameTypeRequiredDescription
codestringYesJavaScript source code to check
{
"valid": true,
"message": "JavaScript syntax is valid",
"codeLength": 87,
"normalized": false,
"transformations": []
}
const result = await client.exec.validate.validateSyntax({
code: "function add(a, b) { return a + b; }"
});

Transpile TypeScript to JavaScript and return the transpiled output alongside original and transpiled lengths.

This endpoint takes no parameters.

NameTypeRequiredDescription
codestringYesTypeScript source code to validate
{
"valid": true,
"javascript": "export default function greet(name) { return \"Hello, \" + name; }",
"originalLength": 64,
"transpiledLength": 72,
"normalized": false,
"transformations": [],
"message": "TypeScript validation successful"
}
const result = await client.exec.validate.validateTypeScript({
code: "function greet(name: string): string { return `Hello, ${name}`; }"
});

Detect import and require statements in the provided source, compare them against installed modules, and produce an install command for any missing packages.

This endpoint takes no parameters.

NameTypeRequiredDescription
codestringYesSource code whose imports will be checked
{
"totalModules": 4,
"allInstalled": false,
"missingCount": 2,
"missingModules": ["lodash", "dayjs"],
"dependencies": [
{ "name": "lodash", "declared": true, "installed": false },
{ "name": "dayjs", "declared": true, "installed": false },
{ "name": "fs", "declared": true, "installed": true },
{ "name": "path", "declared": true, "installed": true }
],
"message": "2 of 4 modules are missing",
"installCommand": "npm install lodash dayjs"
}
const result = await client.exec.validate.validateDependencies({
code: "import _ from 'lodash'; import dayjs from 'dayjs'; import fs from 'fs';"
});

Parse magic comments and the declared return type embedded in the source. Magic comments are short directives prefixed with /* hoody */ style markers that configure execution behavior.

This endpoint takes no parameters.

NameTypeRequiredDescription
codestringYesSource code containing magic comments
{
"magicComments": {
"returns": "{ status: number, body: string }",
"timeout": 30000
},
"returnType": {
"definition": "{ status: number, body: string }",
"mode": "inline",
"location": "line:1 col:18"
},
"message": "Magic comments parsed successfully"
}
const result = await client.exec.validate.validateMagicComments({
code: "/* hoody returns { status: number, body: string} */ export default async function() { return { status: 200, body: 'ok' }; }"
});

Validate an arbitrary JSON value against a TypeScript-style typeDefinition. Use this to confirm that a script’s return value conforms to the contract declared in its magic comments.

This endpoint takes no parameters.

NameTypeRequiredDescription
typeDefinitionstringYesTypeScript-style type definition (e.g. { status: number, body: string })
valueanyYesArbitrary JSON value to validate against the declared return type
{
"valid": true,
"errors": [],
"typeDefinition": "{ status: number, body: string }",
"parsedType": {
"kind": "object",
"properties": {
"status": { "kind": "primitive", "type": "number" },
"body": { "kind": "primitive", "type": "string" }
}
},
"message": "Value matches type definition"
}
const result = await client.exec.validate.validateReturnType({
typeDefinition: "{ status: number, body: string }",
value: { status: 200, body: "ok" }
});