Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

parseWithStandardSchema.md

45 lines814 Bytes

1---
2id: parseWithStandardSchema
3title: parseWithStandardSchema
4---
5​
6```ts
7function parseWithStandardSchema<T>(schema, data): T;
8```
9​
10Defined in: [packages/ai/src/activities/chat/tools/schema-converter.ts:468](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/tools/schema-converter.ts#L468)
11​
12Synchronously validates data against a Standard Schema compliant schema.
13Note: Some Standard Schema implementations may only support async validation.
14In those cases, this function will throw.
15​
16## Type Parameters
17​
18### T
19​
20`T`
21​
22## Parameters
23​
24### schema
25​
26`unknown`
27​
28Standard Schema compliant schema
29​
30### data
31​
32`unknown`
33​
34Data to validate
35​
36## Returns
37​
38`T`
39​
40Parsed/validated data
41​
42## Throws
43​
44StandardSchemaValidationError if validation fails; Error if the
45 schema only supports async validation.