@@ -80,7 +80,7 @@ export class SchemaError extends Error {
80
80
* @returns A new schema instance.
81
81
*/
82
82
function createSchema < TOutput = unknown , TInput = unknown > (
83
- safeParse : ( input : TInput ) => Result < TOutput >
83
+ safeParse : ( input : TInput ) => Result < TOutput > ,
84
84
) : Schema < TOutput , TInput > {
85
85
/**
86
86
* Parses the input data and returns the validated output.
@@ -115,7 +115,7 @@ function createSchema<TOutput = unknown, TInput = unknown>(
115
115
*/
116
116
function prependKeyToIssues (
117
117
key : PropertyKey ,
118
- issues : readonly Issue [ ]
118
+ issues : readonly Issue [ ] ,
119
119
) : Issue [ ] {
120
120
return issues . map ( ( issue ) => ( {
121
121
...issue ,
@@ -168,7 +168,7 @@ export function boolean(message = "Expected boolean"): Schema<boolean> {
168
168
*/
169
169
export function array < T extends Schema > (
170
170
schema : T ,
171
- message = "Expected array"
171
+ message = "Expected array" ,
172
172
) : Schema < InferOutput < T > [ ] > {
173
173
return createSchema < InferOutput < T > [ ] > ( ( input ) => {
174
174
if ( ! Array . isArray ( input ) ) return { issues : [ { message } ] } ;
@@ -218,7 +218,7 @@ export interface ObjectSchema<TOutput extends RawShape, TInput = unknown>
218
218
*/
219
219
export function object < T extends RawShape > (
220
220
shape : ObjectShape < T > ,
221
- message = "Expected object"
221
+ message = "Expected object" ,
222
222
) : ObjectSchema < T > {
223
223
return {
224
224
shape,
@@ -244,7 +244,7 @@ export function object<T extends RawShape>(
244
244
* @returns A schema that validates inputs that can be `null`, `undefined`, or match the provided schema.
245
245
*/
246
246
export function maybe < T extends Schema > (
247
- schema : T
247
+ schema : T ,
248
248
) : Schema < InferOutput < T > | undefined > {
249
249
return createSchema < InferOutput < T > | undefined > ( ( value ) => {
250
250
if ( null === value || undefined === value ) return { value : undefined } ;
@@ -261,7 +261,7 @@ export function maybe<T extends Schema>(
261
261
*/
262
262
export function defaulted < T extends Schema > (
263
263
schema : T ,
264
- defaultValue : InferOutput < T >
264
+ defaultValue : InferOutput < T > ,
265
265
) : Schema < InferOutput < T > > {
266
266
return createSchema < InferOutput < T > > ( ( value ) => {
267
267
if ( null === value || undefined === value ) return { value : defaultValue } ;
0 commit comments