Open History to see the last commit
1export type TStandardSchemaValidatorValue<out TData> = {
2 value: TData
3}
4β
5export type TStandardSchemaValidatorIssue = Array<StandardSchemaV1Issue>
6β
7/**
8 * The Standard Schema interface.
9 */
10export type StandardSchemaV1<out TInput = unknown, out TOutput = TInput> = {
11 /**
12 * The Standard Schema properties.
13 */
14 readonly '~standard': StandardSchemaV1Props<TInput, TOutput>
15}
16β
17/**
18 * The Standard Schema properties interface.
19 */
20interface StandardSchemaV1Props<out TInput = unknown, out TOutput = TInput> {
21 /**
22 * The version number of the standard.
23 */
24 readonly version: 1
25 /**
26 * The vendor name of the schema library.
27 */
28 readonly vendor: string
29 /**
30 * Validates unknown input values.
31 */
32 readonly validate: (
33 value: unknown,
34 ) =>
35 StandardSchemaV1Result<TOutput> | Promise<StandardSchemaV1Result<TOutput>>
36 /**
37 * Inferred types associated with the schema.
38 */
39 readonly types?: StandardSchemaV1Types<TInput, TOutput> | undefined
40}
41/**
42 * The result interface of the validate function.
43 */
44type StandardSchemaV1Result<TOutput> =
45 StandardSchemaV1SuccessResult<TOutput> | StandardSchemaV1FailureResult
46/**
47 * The result interface if validation succeeds.
48 */
49interface StandardSchemaV1SuccessResult<out TOutput> {
50 /**
51 * The typed output value.
52 */
53 readonly value: TOutput
54 /**
55 * The non-existent issues.
56 */
57 readonly issues?: undefined
58}
59/**
60 * The result interface if validation fails.
61 */
62interface StandardSchemaV1FailureResult {
63 /**
64 * The issues of failed validation.
65 */
66 readonly issues: ReadonlyArray<StandardSchemaV1Issue>
67}
68/**
69 * The issue interface of the failure output.
70 */
71export interface StandardSchemaV1Issue {
72 /**
73 * The error message of the issue.
74 */
75 readonly message: string
76 /**
77 * The path of the issue, if any.
78 */
79 readonly path?:
80 ReadonlyArray<PropertyKey | StandardSchemaV1PathSegment> | undefined
81}
82/**
83 * The path segment interface of the issue.
84 */
85interface StandardSchemaV1PathSegment {
86 /**
87 * The key representing a path segment.
88 */
89 readonly key: PropertyKey
90}
91/**
92 * The Standard Schema types interface.
93 */
94interface StandardSchemaV1Types<out TInput = unknown, out TOutput = TInput> {
95 /**
96 * The input type of the schema.
97 */
98 readonly input: TInput
99 /**
100 * The output type of the schema.
101 */
102 readonly output: TOutput
103}