-
Notifications
You must be signed in to change notification settings - Fork 0
/
type.d.ts
58 lines (48 loc) · 1.74 KB
/
type.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {
AnySchema,
ArraySchema,
StringSchema,
NumberSchema,
BooleanSchema,
DateSchema
} from 'yup';
export function conditional<T extends AnySchema, Value extends any>(
createType: (value: Value) => T
): T;
export function depends<T extends AnySchema, PropertyValues extends Array<V>, V extends any>(
propertyNames: string[],
baseType: T,
createType: (propertyValues: PropertyValues, baseType: T) => T
): T;
export function filter<V, T extends AnySchema<V>>(type: T, test: (value: V) => boolean): T;
interface ArrayOfOneOfOptions {
nonEmpty?: boolean;
allowEmpty?: boolean;
}
// "TypeScript integration: how to use ArraySchema properly?"
// https://github.com/jquense/yup/issues/1839
export function arrayOfOneOf<
ArrayType extends any[] | null | undefined,
T extends AnySchema<V>,
Values extends Array<V>,
V extends any,
ArraySchemaContext = unknown
>(
type: T,
values: Values,
options?: ArrayOfOneOfOptions
): ArraySchema<ArrayType, ArraySchemaContext>;
interface OneOfOptions {
required?: boolean;
}
export function oneOf(values: string[], options?: OneOfOptions): StringSchema;
export function oneOf(values: number[], options?: OneOfOptions): NumberSchema;
export function oneOf(values: boolean[], options?: OneOfOptions): BooleanSchema;
export function oneOf(values: Date[], options?: OneOfOptions): DateSchema;
export function oneOf<T extends AnySchema<V>, Values extends Array<V>, V extends any>(type: T, values: Values, options?: OneOfOptions): T;
interface RegExpOptions {
nonEmpty?: boolean;
allowEmpty?: boolean;
}
export function regexp(regularExpression: RegExp, options?: RegExpOptions): StringSchema;
export function regexp<T extends StringSchema>(type: T, regularExpression: RegExp, options?: RegExpOptions): T;