tiny-decoders
Advanced tools
Comparing version 6.0.1 to 7.0.0
@@ -1,2 +0,2 @@ | ||
export declare type Decoder<T, U = unknown> = (value: U, errors?: Array<DecoderError>) => T; | ||
export declare type Decoder<T, U = unknown> = (value: U) => T; | ||
declare type WithUndefinedAsOptional<T> = T extends Record<string, unknown> ? Expand<{ | ||
@@ -19,21 +19,9 @@ [P in OptionalKeys<T>]?: T[P]; | ||
export declare function string(value: unknown): string; | ||
export declare function stringUnion<T extends Record<string, null>>(mapping: keyof T extends string ? keyof T extends never ? "stringUnion must have at least one key" : T : { | ||
[P in keyof T]: P extends number ? "stringUnion keys must be strings, not numbers" : T[P]; | ||
export declare function stringUnion<T extends Record<string, unknown>>(mapping: keyof T extends string ? keyof T extends never ? "stringUnion must have at least one key" : T : { | ||
[P in keyof T]: P extends number ? ["stringUnion keys must be strings, not numbers", never] : T[P]; | ||
}): Decoder<keyof T>; | ||
export declare function array<T, U = never>(decoder: Decoder<T>, { mode }?: { | ||
mode?: "skip" | "throw" | { | ||
default: U; | ||
}; | ||
}): Decoder<Array<T | U>>; | ||
export declare function record<T, U = never>(decoder: Decoder<T>, { mode }?: { | ||
mode?: "skip" | "throw" | { | ||
default: U; | ||
}; | ||
}): Decoder<Record<string, T | U>>; | ||
export declare function fields<T>(callback: (field: <U, V = never>(key: string, decoder: Decoder<U>, options?: { | ||
mode?: "throw" | { | ||
default: V; | ||
}; | ||
}) => U | V, object: Record<string, unknown>, errors?: Array<DecoderError>) => T, { exact, allow, }?: { | ||
exact?: "allow extra" | "push" | "throw"; | ||
export declare function array<T>(decoder: Decoder<T>): Decoder<Array<T>>; | ||
export declare function record<T>(decoder: Decoder<T>): Decoder<Record<string, T>>; | ||
export declare function fields<T>(callback: (field: <U>(key: string, decoder: Decoder<U>) => U, object: Record<string, unknown>) => T, { exact, allow, }?: { | ||
exact?: "allow extra" | "throw"; | ||
allow?: "array" | "object"; | ||
@@ -44,3 +32,3 @@ }): Decoder<WithUndefinedAsOptional<T>>; | ||
}, { exact }?: { | ||
exact?: "allow extra" | "push" | "throw"; | ||
exact?: "allow extra" | "throw"; | ||
}): Decoder<WithUndefinedAsOptional<T>>; | ||
@@ -47,0 +35,0 @@ declare type Values<T> = T[keyof T]; |
{ | ||
"name": "tiny-decoders", | ||
"version": "6.0.1", | ||
"version": "7.0.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "Simon Lydell", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35958
962