diff --git a/README.md b/README.md index 86894f2a6..d90bbebb5 100644 --- a/README.md +++ b/README.md @@ -1247,7 +1247,7 @@ import { mixed, InferType } from 'yup'; let objectIdSchema = yup .mixed((input): input is ObjectId => input instanceof ObjectId) .transform((value: any, input, ctx) => { - if (ctx.typeCheck(value)) return value; + if (ctx.isType(value)) return value; return new ObjectId(value); }); diff --git a/src/object.ts b/src/object.ts index 5b307b302..3aac8b94e 100644 --- a/src/object.ts +++ b/src/object.ts @@ -316,7 +316,11 @@ export default class ObjectSchema< } return next.withMutation((s: any) => - s.setFields(nextFields, this._excludedEdges), + // XXX: excludes here is wrong + s.setFields(nextFields, [ + ...this._excludedEdges, + ...schema._excludedEdges, + ]), ); } diff --git a/test/mixed.ts b/test/mixed.ts index be55b5964..154169e8a 100644 --- a/test/mixed.ts +++ b/test/mixed.ts @@ -957,7 +957,7 @@ describe('Mixed Types ', () => { foo: array(number().integer()).required(), bar: string() .max(2) - .default(()=> 'a') + .default(() => 'a') .meta({ input: 'foo' }) .label('str!') .oneOf(['a', 'b']) @@ -966,7 +966,7 @@ describe('Mixed Types ', () => { is: 'entered', then: (s) => s.defined(), }), - baz: tuple([string(), number()]) + baz: tuple([string(), number()]), }); }); @@ -1070,7 +1070,7 @@ describe('Mixed Types ', () => { oneOf: [], notOneOf: [], tests: [], - } + }, ], }, }, @@ -1182,7 +1182,7 @@ describe('Mixed Types ', () => { oneOf: [], notOneOf: [], tests: [], - } + }, ], }, }, diff --git a/test/object.ts b/test/object.ts index d18d11808..2911bf60e 100644 --- a/test/object.ts +++ b/test/object.ts @@ -1005,6 +1005,10 @@ describe('Object types', () => { await expect( schema.concat(object()).isValid({ a1: null }), ).resolves.toEqual(false); + + await expect( + object().concat(schema).isValid({ a1: null }), + ).resolves.toEqual(false); }); it('should handle nested conditionals', () => {