Skip to content

Commit

Permalink
fix: object bug when nested object has a property with strict (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
netochaves committed May 3, 2020
1 parent 95d1401 commit 7f52b8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/object.js
Expand Up @@ -88,7 +88,7 @@ inherits(ObjectSchema, MixedSchema, {
let innerOptions = {
...options,
parent: intermediateValue,
__validating: false,
__validating: options.__validating || false,
};

let isChanged = false;
Expand Down
14 changes: 14 additions & 0 deletions test/object.js
Expand Up @@ -146,6 +146,20 @@ describe('Object types', () => {
err.message.should.match(/must be a `string` type/);
});

it('should respect strict for nested object values', async () => {
inst = object({
obj: object({
field: string().strict(),
}),
});

let err = await inst
.validate({ obj: { field: 5 } })
.should.be.rejected();

err.message.should.match(/must be a `string` type/);
});

it('should respect child schema with strict()', async () => {
inst = object({
field: number().strict(),
Expand Down

0 comments on commit 7f52b8a

Please sign in to comment.