@types/yup
Advanced tools
Comparing version 0.28.3 to 0.29.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for yup 0.28 | ||
// Type definitions for yup 0.29 | ||
// Project: https://github.com/jquense/yup | ||
@@ -15,2 +15,3 @@ // Definitions by: Dominik Hardtke <https://github.com/dhardtke>, | ||
// Elías García <https://github.com/elias-garcia> | ||
// Ian Sanders <https://github.com/iansan5653> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
@@ -79,10 +80,14 @@ // TypeScript Version: 3.6 | ||
// Note: Using `{} | null | undefined` allows excluding `null` & `undefined` | ||
// whereas using `any` as the default type would mean that `nullable(false)`, | ||
// `defined`, and `required` would all have no effect. | ||
export interface MixedSchemaConstructor { | ||
// tslint:disable-next-line:no-unnecessary-generics | ||
<T = any>(): MixedSchema<T>; | ||
<T = {} | null | undefined>(): MixedSchema<T>; | ||
// tslint:disable-next-line:no-unnecessary-generics | ||
new <T = any>(options?: { type?: string; [key: string]: any }): MixedSchema<T>; | ||
new <T = {} | null | undefined>(options?: { type?: string; [key: string]: any }): MixedSchema<T>; | ||
} | ||
export interface MixedSchema<T extends any = NotUndefined> extends Schema<T> { | ||
export interface MixedSchema<T extends any = {} | null | undefined> extends Schema<T> { | ||
nullable(isNullable?: true): MixedSchema<T | null>; | ||
@@ -97,14 +102,12 @@ nullable(isNullable: false): MixedSchema<Exclude<T, null>>; | ||
concat<U>(schema: Schema<U>): MixedSchema<T | U>; | ||
oneOf<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): MixedSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): MixedSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: AssertingTestFunction<U> | ||
): MixedSchema<U>; | ||
test( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: TestFunction | ||
): this; | ||
oneOf<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): MixedSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): MixedSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>(name: string, message: TestOptionsMessage, test: AssertingTestFunction<U>): MixedSchema<U>; | ||
test(name: string, message: TestOptionsMessage, test: TestFunction): this; | ||
test<U extends T = T>(options: AssertingTestOptions<U, Record<string, any>>): MixedSchema<U>; | ||
@@ -115,7 +118,7 @@ test(options: TestOptions<Record<string, any>>): this; | ||
export interface StringSchemaConstructor { | ||
<T extends string | null | undefined = string>(): T extends string ? StringSchema<T> : StringSchema; | ||
new <T extends string | null | undefined = string>(): T extends string ? StringSchema<T> : StringSchema; | ||
(): StringSchema; | ||
new (): StringSchema; | ||
} | ||
export interface StringSchema<T extends string | null | undefined = string> extends Schema<T> { | ||
export interface StringSchema<T extends string | null | undefined = string | undefined> extends Schema<T> { | ||
length(limit: number | Ref, message?: StringLocale['length']): StringSchema<T>; | ||
@@ -142,14 +145,12 @@ min(limit: number | Ref, message?: StringLocale['min']): StringSchema<T>; | ||
notRequired(): StringSchema<T | undefined>; | ||
oneOf<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): StringSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): StringSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: AssertingTestFunction<U> | ||
): StringSchema<U>; | ||
test( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: TestFunction | ||
): this; | ||
oneOf<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): StringSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): StringSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>(name: string, message: TestOptionsMessage, test: AssertingTestFunction<U>): StringSchema<U>; | ||
test(name: string, message: TestOptionsMessage, test: TestFunction): this; | ||
test<U extends T = T>(options: AssertingTestOptions<U, Record<string, any>>): StringSchema<U>; | ||
@@ -165,3 +166,3 @@ test(options: TestOptions<Record<string, any>>): this; | ||
export interface NumberSchema<T extends number | null | undefined = number> extends Schema<T> { | ||
export interface NumberSchema<T extends number | null | undefined = number | undefined> extends Schema<T> { | ||
min(limit: number | Ref, message?: NumberLocale['min']): NumberSchema<T>; | ||
@@ -182,14 +183,12 @@ max(limit: number | Ref, message?: NumberLocale['max']): NumberSchema<T>; | ||
notRequired(): NumberSchema<T | undefined>; | ||
oneOf<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): NumberSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): NumberSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: AssertingTestFunction<U> | ||
): NumberSchema<U>; | ||
test( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: TestFunction | ||
): this; | ||
oneOf<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): NumberSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): NumberSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>(name: string, message: TestOptionsMessage, test: AssertingTestFunction<U>): NumberSchema<U>; | ||
test(name: string, message: TestOptionsMessage, test: TestFunction): this; | ||
test<U extends T = T>(options: AssertingTestOptions<U, Record<string, any>>): NumberSchema<U>; | ||
@@ -205,3 +204,3 @@ test(options: TestOptions<Record<string, any>>): this; | ||
export interface BooleanSchema<T extends boolean | null | undefined = boolean> extends Schema<T> { | ||
export interface BooleanSchema<T extends boolean | null | undefined = boolean | undefined> extends Schema<T> { | ||
nullable(isNullable?: true): BooleanSchema<T | null>; | ||
@@ -213,14 +212,12 @@ nullable(isNullable: false): BooleanSchema<Exclude<T, null>>; | ||
notRequired(): BooleanSchema<T | undefined>; | ||
oneOf<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): BooleanSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): BooleanSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: AssertingTestFunction<U> | ||
): BooleanSchema<U>; | ||
test( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: TestFunction | ||
): this; | ||
oneOf<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): BooleanSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): BooleanSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>(name: string, message: TestOptionsMessage, test: AssertingTestFunction<U>): BooleanSchema<U>; | ||
test(name: string, message: TestOptionsMessage, test: TestFunction): this; | ||
test<U extends T = T>(options: AssertingTestOptions<U, Record<string, any>>): BooleanSchema<U>; | ||
@@ -236,3 +233,3 @@ test(options: TestOptions<Record<string, any>>): this; | ||
export interface DateSchema<T extends Date | null | undefined = Date> extends Schema<T> { | ||
export interface DateSchema<T extends Date | null | undefined = Date | undefined> extends Schema<T> { | ||
min(limit: Date | string | Ref, message?: DateLocale['min']): DateSchema<T>; | ||
@@ -246,14 +243,12 @@ max(limit: Date | string | Ref, message?: DateLocale['max']): DateSchema<T>; | ||
notRequired(): DateSchema<T | undefined>; | ||
oneOf<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): DateSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): DateSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: AssertingTestFunction<U> | ||
): DateSchema<U>; | ||
test( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: TestFunction | ||
): this; | ||
oneOf<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): DateSchema<MaintainOptionality<T, U>>; | ||
equals<U extends T>( | ||
arrayOfValues: ReadonlyArray<U | Ref>, | ||
message?: MixedLocale['oneOf'], | ||
): DateSchema<MaintainOptionality<T, U>>; | ||
test<U extends T = T>(name: string, message: TestOptionsMessage, test: AssertingTestFunction<U>): DateSchema<U>; | ||
test(name: string, message: TestOptionsMessage, test: TestFunction): this; | ||
test<U extends T = T>(options: AssertingTestOptions<U, Record<string, any>>): DateSchema<U>; | ||
@@ -265,4 +260,4 @@ test(options: TestOptions<Record<string, any>>): this; | ||
export interface ArraySchemaConstructor { | ||
<T>(schema?: Schema<T>): ArraySchema<T>; | ||
new (): ArraySchema<{}>; | ||
<T>(schema?: Schema<T>): NotRequiredArraySchema<T>; | ||
new (): NotRequiredArraySchema<{}>; | ||
} | ||
@@ -350,7 +345,7 @@ | ||
export interface ObjectSchemaConstructor { | ||
<T extends object>(fields?: ObjectSchemaDefinition<T>): ObjectSchema<T>; | ||
<T extends object>(fields?: ObjectSchemaDefinition<T>): ObjectSchema<T | undefined>; | ||
new (): ObjectSchema<{}>; | ||
} | ||
export interface ObjectSchema<T extends object | null | undefined = object> extends Schema<T> { | ||
export interface ObjectSchema<T extends object | null | undefined = object | undefined> extends Schema<T> { | ||
fields: { | ||
@@ -379,14 +374,6 @@ [k in keyof T]: Schema<T[k]>; | ||
concat<U extends object>(schema: ObjectSchema<U>): ObjectSchema<T & U>; | ||
oneOf<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): ObjectSchema<U>; | ||
equals<U extends T>(arrayOfValues: ReadonlyArray<U | Ref | null>, message?: MixedLocale['oneOf']): ObjectSchema<U>; | ||
test<U extends T = T>( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: AssertingTestFunction<U> | ||
): ObjectSchema<U>; | ||
test( | ||
name: string, | ||
message: TestOptionsMessage, | ||
test: TestFunction | ||
): this; | ||
oneOf<U extends T>(arrayOfValues: ReadonlyArray<U | Ref>, message?: MixedLocale['oneOf']): ObjectSchema<U>; | ||
equals<U extends T>(arrayOfValues: ReadonlyArray<U | Ref>, message?: MixedLocale['oneOf']): ObjectSchema<U>; | ||
test<U extends T = T>(name: string, message: TestOptionsMessage, test: AssertingTestFunction<U>): ObjectSchema<U>; | ||
test(name: string, message: TestOptionsMessage, test: TestFunction): this; | ||
test<U extends T = T>(options: AssertingTestOptions<U, Record<string, any>>): ObjectSchema<U>; | ||
@@ -396,3 +383,6 @@ test(options: TestOptions<Record<string, any>>): this; | ||
export type TestFunction = (this: TestContext, value: any) => boolean | ValidationError | Promise<boolean | ValidationError>; | ||
export type TestFunction = ( | ||
this: TestContext, | ||
value: any, | ||
) => boolean | ValidationError | Promise<boolean | ValidationError>; | ||
export type AssertingTestFunction<T> = (this: TestContext, value: any) => value is T; | ||
@@ -504,7 +494,7 @@ | ||
export type TestOptions<P extends Record<string, any> = {}> = | ||
NonExclusiveTestOptions<P> | ExclusiveTestOptions<P>; | ||
export type TestOptions<P extends Record<string, any> = {}> = NonExclusiveTestOptions<P> | ExclusiveTestOptions<P>; | ||
export type AssertingTestOptions<U, P extends Record<string, any> = {}> = | ||
NonExclusiveAssertingTestOptions<U, P> | ExclusiveAssertingTestOptions<U, P>; | ||
| NonExclusiveAssertingTestOptions<U, P> | ||
| ExclusiveAssertingTestOptions<U, P>; | ||
@@ -676,2 +666,1 @@ export interface SchemaFieldRefDescription { | ||
type MaintainOptionality<T, U> = T extends undefined ? U | undefined : U; | ||
type NotUndefined = string | number | boolean | symbol | object | null; |
{ | ||
"name": "@types/yup", | ||
"version": "0.28.3", | ||
"version": "0.29.0", | ||
"description": "TypeScript definitions for yup", | ||
@@ -66,2 +66,7 @@ "license": "MIT", | ||
"githubUsername": "elias-garcia" | ||
}, | ||
{ | ||
"name": "Ian Sanders", | ||
"url": "https://github.com/iansan5653", | ||
"githubUsername": "iansan5653" | ||
} | ||
@@ -78,4 +83,4 @@ ], | ||
"dependencies": {}, | ||
"typesPublisherContentHash": "f5153506cbc20b41b54c1590fb35c74ee2ce7d82717b735fdb4e3a1efdbd3ff9", | ||
"typesPublisherContentHash": "bab01c61408b160554fa2339a93c2ffa3c7f1d196f3566bc87c8232c970a9f00", | ||
"typeScriptVersion": "3.6" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Mon, 11 May 2020 15:13:07 GMT | ||
* Last updated: Tue, 19 May 2020 20:54:56 GMT | ||
* Dependencies: none | ||
@@ -17,2 +17,2 @@ * Global values: none | ||
# Credits | ||
These definitions were written by [Dominik Hardtke](https://github.com/dhardtke), [Vladyslav Tserman](https://github.com/vtserman), [Moreton Bay Regional Council](https://github.com/MoretonBayRC), [Sindre Seppola](https://github.com/sseppola), [Yash Kulshrestha](https://github.com/YashdalfTheGray), [Vincent Pizzo](https://github.com/vincentjames501), [Robert Bullen](https://github.com/robertbullen), [Yusuke Sato](https://github.com/sat0yu), [Desmond Koh](https://github.com/deskoh), [Maurice de Beijer](https://github.com/mauricedb), [Kalley Powell](https://github.com/kalley), and [Elías García](https://github.com/elias-garcia). | ||
These definitions were written by [Dominik Hardtke](https://github.com/dhardtke), [Vladyslav Tserman](https://github.com/vtserman), [Moreton Bay Regional Council](https://github.com/MoretonBayRC), [Sindre Seppola](https://github.com/sseppola), [Yash Kulshrestha](https://github.com/YashdalfTheGray), [Vincent Pizzo](https://github.com/vincentjames501), [Robert Bullen](https://github.com/robertbullen), [Yusuke Sato](https://github.com/sat0yu), [Desmond Koh](https://github.com/deskoh), [Maurice de Beijer](https://github.com/mauricedb), [Kalley Powell](https://github.com/kalley), [Elías García](https://github.com/elias-garcia), and [Ian Sanders](https://github.com/iansan5653). |
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
31693
578