MCPcopy
hub / github.com/ianstormtaylor/superstruct / assert

Function assert

src/struct.ts:123–133  ·  view source on GitHub ↗
(
  value: unknown,
  struct: Struct<T, S>,
  message?: string
)

Source from the content-addressed store, hash-verified

121 */
122
123export function assert<T, S>(
124 value: unknown,
125 struct: Struct<T, S>,
126 message?: string
127): asserts value is T {
128 const result = validate(value, struct, { message })
129
130 if (result[0]) {
131 throw result[0]
132 }
133}
134
135/**
136 * Create a value with the coercion logic of struct and validate it.

Callers 15

deprecated.test.tsFile · 0.90
valid-reference.tsFile · 0.90
assert.test.tsFile · 0.90
deprecated.tsFile · 0.90
infer.tsFile · 0.90
nullable.tsFile · 0.90
empty.tsFile · 0.90
bigint.tsFile · 0.90
trimmed.tsFile · 0.90
type.tsFile · 0.90
partial.tsFile · 0.90

Calls 1

validateFunction · 0.85

Tested by

no test coverage detected