Code Validation
Section titled “Code Validation”The Code Validation endpoints let you statically inspect a piece of source code without executing it. They cover JavaScript syntax checks, TypeScript transpilation, dependency presence, magic-comment parsing, return-type conformance, and a combined full-script validation. Use these endpoints from editor tooling, CI pipelines, or pre-flight checks before persisting or executing user-authored scripts.
All endpoints are scoped to a container and accept a JSON body containing the code (or the type definition and value, for return-type checks). Each request returns a structured result describing what was detected; validation failures are reported in the 200 payload rather than as HTTP errors.
Validate Syntax
Section titled “Validate Syntax”POST /api/v1/exec/validate/syntax
Checks whether the submitted source code parses as valid JavaScript.
This endpoint takes no parameters.
Request Body
Section titled “Request Body”| Name | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Source code to validate |
{ "code": "const greet = (name) => `Hello, ${name}!`;\nconsole.log(greet('Hoody'));"}Response
Section titled “Response”{ "valid": true, "message": "JavaScript syntax is valid", "codeLength": 76, "normalized": false, "transformations": []}{ "error": "Invalid parameter format", "code": "VALIDATION_ERROR", "timestamp": "2026-01-15T10:42:18.314Z"}| Error Code | Title | Description | Resolution |
|---|---|---|---|
VALIDATION_ERROR | Invalid input | Request parameters failed validation | Check parameter format and requirements |
{ "error": "Internal server error", "code": "ERROR_500", "timestamp": "2026-01-15T10:42:18.314Z"}SDK Usage
Section titled “SDK Usage”import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.exec.validate.validateSyntax({ code: "const greet = (name) => `Hello, ${name}!`;\nconsole.log(greet('Hoody'));" });curl -X POST "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/validate/syntax" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "code": "const greet = (name) => `Hello, ${name}!`;\nconsole.log(greet(\"Hoody\"));" }'Validate TypeScript
Section titled “Validate TypeScript”POST /api/v1/exec/validate/typescript
Transpiles TypeScript to JavaScript and reports the result, including byte-length deltas and any normalization transformations applied to the input.
This endpoint takes no parameters.
Request Body
Section titled “Request Body”| Name | Type | Required | Description |
|---|---|---|---|
code | string | Yes | TypeScript source code to validate |
{ "code": "type Greeting = { name: string };\nconst greet = (g: Greeting): string => `Hello, ${g.name}!`;"}Response
Section titled “Response”{ "valid": true, "javascript": "const greet = (g) => `Hello, ${g.name}!`;\n", "originalLength": 92, "transpiledLength": 41, "normalized": false, "transformations": [], "message": "TypeScript validation successful"}{ "error": "Invalid parameter format", "code": "VALIDATION_ERROR", "timestamp": "2026-01-15T10:42:18.314Z"}| Error Code | Title | Description | Resolution |
|---|---|---|---|
VALIDATION_ERROR | Invalid input | Request parameters failed validation | Check parameter format and requirements |
{ "error": "Internal server error", "code": "ERROR_500", "timestamp": "2026-01-15T10:42:18.314Z"}SDK Usage
Section titled “SDK Usage”import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.exec.validate.validateTypeScript({ code: "type Greeting = { name: string };\nconst greet = (g: Greeting): string => `Hello, ${g.name}!`;" });curl -X POST "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/validate/typescript" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "code": "type Greeting = { name: string };\nconst greet = (g: Greeting): string => `Hello, ${g.name}!`;" }'Validate Dependencies
Section titled “Validate Dependencies”POST /api/v1/exec/validate/dependencies
Inspects the source code for imported or required modules and reports which ones are missing from the container’s runtime environment, along with a suggested install command.
This endpoint takes no parameters.
Request Body
Section titled “Request Body”| Name | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Source code to inspect for module dependencies |
{ "code": "import lodash from 'lodash';\nimport { z } from 'zod';\n\nconst schema = z.object({ name: z.string() });\nconst result = lodash.camelCase(schema.parse({ name: 'Hello World' }).name);\nconsole.log(result);"}Response
Section titled “Response”{ "totalModules": 2, "allInstalled": false, "missingCount": 1, "missingModules": ["zod"], "dependencies": [ { "module": "lodash", "installed": true, "version": "4.17.21" }, { "module": "zod", "installed": false, "version": null } ], "message": "1 module(s) missing: zod", "installCommand": "npm install zod"}{ "error": "Invalid parameter format", "code": "VALIDATION_ERROR", "timestamp": "2026-01-15T10:42:18.314Z"}| Error Code | Title | Description | Resolution |
|---|---|---|---|
VALIDATION_ERROR | Invalid input | Request parameters failed validation | Check parameter format and requirements |
{ "error": "Internal server error", "code": "ERROR_500", "timestamp": "2026-01-15T10:42:18.314Z"}SDK Usage
Section titled “SDK Usage”import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.exec.validate.validateDependencies({ code: "import lodash from 'lodash';\nimport { z } from 'zod';\nconsole.log(lodash.camelCase('hello world'));" });curl -X POST "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/validate/dependencies" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "code": "import lodash from \"lodash\";\nimport { z } from \"zod\";\nconsole.log(lodash.camelCase(\"hello world\"));" }'Validate Magic Comments
Section titled “Validate Magic Comments”POST /api/v1/exec/validate/magic-comments
Parses and validates the magic-comment directives embedded at the top of a script (such as @timeout, @memory, @network) and detects any numeric directives whose value was malformed and therefore fell back to its default.
This endpoint takes no parameters.
Request Body
Section titled “Request Body”| Name | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Source code whose magic comments should be parsed |
{ "code": "// @timeout 30s\n// @memory 256MB\n// @network\n// @description Run a long batch job\n\nasync function run() { /* ... */ }\nreturn run();"}Response
Section titled “Response”{ "magicComments": { "timeout": "30s", "memory": "256MB", "network": true, "description": "Run a long batch job" }, "warnings": [], "returnType": { "definition": "Promise<void>", "mode": "async", "location": "function run(): Promise<void>" }, "message": "Magic comments parsed successfully"}{ "error": "Invalid parameter format", "code": "VALIDATION_ERROR", "timestamp": "2026-01-15T10:42:18.314Z"}| Error Code | Title | Description | Resolution |
|---|---|---|---|
VALIDATION_ERROR | Invalid input | Request parameters failed validation | Check parameter format and requirements |
{ "error": "Internal server error", "code": "ERROR_500", "timestamp": "2026-01-15T10:42:18.314Z"}SDK Usage
Section titled “SDK Usage”import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.exec.validate.validateMagicComments({ code: "// @timeout 30s\n// @memory 256MB\n// @network\nasync function run() { /* ... */ }\nreturn run();" });curl -X POST "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/validate/magic-comments" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "code": "// @timeout 30s\n// @memory 256MB\n// @network\nasync function run() { /* ... */ }\nreturn run();" }'Validate Return Type
Section titled “Validate Return Type”POST /api/v1/exec/validate/return-type
Checks whether a JSON value conforms to a declared TypeScript-style type definition. The endpoint parses the type definition, walks it against the supplied value, and returns any structural mismatches it finds.
This endpoint takes no parameters.
Request Body
Section titled “Request Body”| Name | Type | Required | Description |
|---|---|---|---|
typeDefinition | string | Yes | TypeScript-style type definition to validate against |
value | any | Yes | Arbitrary JSON value to validate against the declared return type |
{ "typeDefinition": "{ id: string; tags: string[]; meta: { version: number } }", "value": { "id": "doc-001", "tags": ["alpha", "beta"], "meta": { "version": 3 } }}Response
Section titled “Response”{ "valid": true, "errors": [], "typeDefinition": "{ id: string; tags: string[]; meta: { version: number } }", "parsedType": { "kind": "object", "properties": { "id": { "kind": "primitive", "type": "string" }, "tags": { "kind": "array", "items": { "kind": "primitive", "type": "string" } }, "meta": { "kind": "object", "properties": { "version": { "kind": "primitive", "type": "number" } } } } }, "message": "Value matches declared return type"}{ "error": "Invalid parameter format", "code": "VALIDATION_ERROR", "timestamp": "2026-01-15T10:42:18.314Z"}| Error Code | Title | Description | Resolution |
|---|---|---|---|
VALIDATION_ERROR | Invalid input | Request parameters failed validation | Check parameter format and requirements |
{ "error": "Internal server error", "code": "ERROR_500", "timestamp": "2026-01-15T10:42:18.314Z"}SDK Usage
Section titled “SDK Usage”import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.exec.validate.validateReturnType({ typeDefinition: "{ id: string; tags: string[]; meta: { version: number } }", value: { id: "doc-001", tags: ["alpha", "beta"], meta: { version: 3 } }});curl -X POST "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/validate/return-type" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "typeDefinition": "{ id: string; tags: string[]; meta: { version: number } }", "value": { "id": "doc-001", "tags": ["alpha", "beta"], "meta": { "version": 3 } } }'Validate Script
Section titled “Validate Script”POST /api/v1/exec/validate/script
Runs every per-aspect validator (syntax, TypeScript, dependencies, magic comments) against the same piece of code in a single request. This is the recommended endpoint for full pre-flight checks before persisting or executing user-authored scripts.
This endpoint takes no parameters.
Request Body
Section titled “Request Body”| Name | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Full script source to validate |
{ "code": "// @timeout 30s\nimport lodash from 'lodash';\n\nconst items: Array<{ id: number; name: string }> = [\n { id: 1, name: 'alpha' },\n { id: 2, name: 'beta' },\n];\n\nreturn lodash.sortBy(items, ['name']);"}Response
Section titled “Response”{ "valid": true, "results": { "syntax": { "valid": true, "message": "JavaScript syntax is valid" }, "typescript": { "valid": true, "transpiledLength": 214 }, "dependencies": { "total": 1, "installed": 1, "missing": 0, "missingModules": [], "allInstalled": true }, "magicComments": { "timeout": "30s" }, "magicCommentWarnings": [], "normalized": false, "transformations": [] }, "message": "Script validation passed"}{ "error": "Invalid parameter format", "code": "VALIDATION_ERROR", "timestamp": "2026-01-15T10:42:18.314Z"}| Error Code | Title | Description | Resolution |
|---|---|---|---|
VALIDATION_ERROR | Invalid input | Request parameters failed validation | Check parameter format and requirements |
{ "error": "Internal server error", "code": "ERROR_500", "timestamp": "2026-01-15T10:42:18.314Z"}SDK Usage
Section titled “SDK Usage”import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.exec.validate.validateScript({ code: "// @timeout 30s\nimport lodash from 'lodash';\nconst items: Array<{ id: number; name: string }> = [{ id: 1, name: 'alpha' }];\nreturn lodash.sortBy(items, ['name']);"});curl -X POST "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/validate/script" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "code": "// @timeout 30s\nimport lodash from \"lodash\";\nconst items: Array<{ id: number; name: string }> = [{ id: 1, name: \"alpha\" }];\nreturn lodash.sortBy(items, [\"name\"]);" }'