Skip to content

Commit

Permalink
Yup: Allow for Ref in oneOf() (DefinitelyTyped#36580)
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricedb authored and RyanCavanaugh committed Jul 1, 2019
1 parent 2c90a28 commit 6c47884
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion types/yup/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface Schema<T> {
default(value: any): this;
default(): T;
typeError(message?: TestOptionsMessage): this;
oneOf(arrayOfValues: T[], message?: TestOptionsMessage): this;
oneOf(arrayOfValues: Array<T | Ref>, message?: TestOptionsMessage): this;
notOneOf(arrayOfValues: any[], message?: TestOptionsMessage): this;
when(keys: string | any[], builder: WhenOptions<this>): this;
test(
Expand Down
5 changes: 5 additions & 0 deletions types/yup/yup-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,11 @@ castPerson.children = ['1', '2', '3'];
castPerson.children = null;
castPerson.children = undefined;

const loginSchema = yup.object({
password: yup.string(),
confirmPassword: yup.string().nullable().oneOf([yup.ref("password"), null]),
});

function wrapper<T>(b: false, msx: MixedSchema<T>): MixedSchema<T>;
function wrapper<T>(b: true, msx: MixedSchema<T>): MixedSchema<T | null>;

Expand Down

0 comments on commit 6c47884

Please sign in to comment.