Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / parseSchema

Function: parseSchema() ​

parseSchema<TName>(name, value): SchemaTypeMap[TName]

Defined in: packages/ts-sdk/src/validators.ts:309

Validates one unknown payload against one generated schema.

Use this for custom transports, persisted payload checks, tests, or tools that need the same runtime validation the SDK applies at the network boundary.

Example:

ts
import { parseSchema } from '@my-swu/simulator-client'

// Parsed values are runtime-validated and statically typed.
const health = parseSchema('health-response', { buildSha: 'development', status: 'ok' })

console.log(health.status)

Type Parameters ​

TName ​

Example:

ts
import { parseSchema } from '@my-swu/simulator-client'

// Parsed values are runtime-validated and statically typed.
const health = parseSchema('health-response', { buildSha: 'development', status: 'ok' })

console.log(health.status)

TName extends keyof SchemaTypeMap

Parameters ​

name ​

Example:

ts
import { parseSchema } from '@my-swu/simulator-client'

// Parsed values are runtime-validated and statically typed.
const health = parseSchema('health-response', { buildSha: 'development', status: 'ok' })

console.log(health.status)

TName

value ​

Example:

ts
import { parseSchema } from '@my-swu/simulator-client'

// Parsed values are runtime-validated and statically typed.
const health = parseSchema('health-response', { buildSha: 'development', status: 'ok' })

console.log(health.status)

unknown

Returns ​

SchemaTypeMap[TName]

Example ​

ts
import { parseSchema } from '@my-swu/simulator-client'

const health = parseSchema('health-response', { buildSha: 'development', status: 'ok' })
console.log(health.status)

See ​

Released under the MIT License.