typebox 1.2.13 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,20 +6,20 @@ export type TRefineAdd<Type extends TSchema = TSchema> = ('~refine' extends keyo
|
|
|
6
6
|
export declare function RefineAdd<Type extends TSchema>(type: Type, refinement: TRefinement<Type>): TRefineAdd<Type>;
|
|
7
7
|
/** Represents a type with embedded Refine check. */
|
|
8
8
|
export type TRefine<Type extends TSchema = TSchema> = (Type & {
|
|
9
|
-
'~refine': TRefinement<
|
|
9
|
+
'~refine': TRefinement<unknown>[];
|
|
10
10
|
});
|
|
11
|
-
export type TRefineCheckCallback<
|
|
12
|
-
export type TRefineErrorCallback<
|
|
13
|
-
export interface TRefinement<
|
|
14
|
-
check: TRefineCheckCallback<
|
|
15
|
-
error: TRefineErrorCallback<
|
|
11
|
+
export type TRefineCheckCallback<Value extends unknown = unknown> = (value: Value) => boolean;
|
|
12
|
+
export type TRefineErrorCallback<Value extends unknown = unknown> = (value: Value) => string;
|
|
13
|
+
export interface TRefinement<Value extends unknown = unknown> {
|
|
14
|
+
check: TRefineCheckCallback<Value>;
|
|
15
|
+
error: TRefineErrorCallback<Value>;
|
|
16
16
|
}
|
|
17
17
|
/** Refines a type with an explicit check */
|
|
18
|
-
export declare function Refine<Type extends TSchema
|
|
18
|
+
export declare function Refine<Type extends TSchema, Value = Static<Type>>(type: Type, check: TRefineCheckCallback<Value>, error: TRefineErrorCallback<Value>): TRefineAdd<Type>;
|
|
19
19
|
/** Refines a type with an explicit check */
|
|
20
|
-
export declare function Refine<Type extends TSchema
|
|
20
|
+
export declare function Refine<Type extends TSchema, Value = Static<Type>>(type: Type, check: TRefineCheckCallback<Value>): TRefineAdd<Type>;
|
|
21
21
|
/** @deprecated Use the error callback signature to generate error message. This overload will be removed in the next version */
|
|
22
|
-
export declare function Refine<Type extends TSchema
|
|
22
|
+
export declare function Refine<Type extends TSchema, Value = Static<Type>>(type: Type, check: TRefineCheckCallback<Value>, message: string): TRefineAdd<Type>;
|
|
23
23
|
/** Returns true if the given value is a TRefinement. */
|
|
24
24
|
export declare function IsRefinement(value: unknown): value is TRefinement;
|
|
25
25
|
/** Returns true if the given value is a TRefine. */
|