Skip to content

validateAgainstShape

validateAgainstShape(data, shapeFields): { valid: true; } | { valid: false; errors: string[]; }

Validate a data payload against shape field definitions.

Shape field types:

  • “number”, “string”, “boolean”: primitive types
  • “wref”: string (reference to another thing)
  • Typed field objects: { type: primitive, description?: string }
  • Nested objects: { fieldName: type, … }
  • Arrays: [elementType]
  • Optional fields: field name ending with ”?” (e.g. “terminal_reason?”: “string”) OR type string ending with ”?” (e.g. “terminal_reason”: “string?”) OR typed object type ending with ”?” (e.g. { type: “string?” })

For v1 this is permissive: validates top-level field existence and basic types. Returns { valid: true } or { valid: false; errors: string[] }.

Record<string, unknown>

Record<string, unknown>

{ valid: true; } | { valid: false; errors: string[]; }