File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -11506,6 +11506,51 @@ describe('document', function() {
1150611506 assert . equal ( subdocs [ 0 ] . value , 'test' ) ;
1150711507 assert . ok ( subdocs [ 1 ] . nestedSettings ) ;
1150811508 } ) ;
11509+
11510+ it ( 'handles validation errors on deeply nested subdocuments underneath a nested path (gh-12021)' , async function ( ) {
11511+ const SubSubSchema = new mongoose . Schema (
11512+ {
11513+ from : {
11514+ type : mongoose . Schema . Types . String ,
11515+ required : true
11516+ }
11517+ } ,
11518+ { _id : false }
11519+ ) ;
11520+
11521+ const SubSchema = new mongoose . Schema (
11522+ {
11523+ nested : {
11524+ type : SubSubSchema ,
11525+ required : false
11526+ }
11527+ } ,
11528+ { _id : false }
11529+ ) ;
11530+
11531+ const TestLeafSchema = new mongoose . Schema ( {
11532+ testProp : {
11533+ testSubProp : {
11534+ type : SubSchema ,
11535+ required : true
11536+ }
11537+ }
11538+ } ) ;
11539+
11540+ const TestLeafModel = mongoose . model ( 'test-leaf-model' , TestLeafSchema ) ;
11541+
11542+ const testModelInstance = new TestLeafModel ( {
11543+ testProp : {
11544+ testSubProp : {
11545+ nested : { from : null }
11546+ }
11547+ }
11548+ } ) ;
11549+
11550+ const err = await testModelInstance . validate ( ) . then ( ( ) => null , err => err ) ;
11551+ assert . ok ( err ) ;
11552+ assert . ok ( err . errors [ 'testProp.testSubProp.nested.from' ] ) ;
11553+ } ) ;
1150911554} ) ;
1151011555
1151111556describe ( 'Check if instance function that is supplied in schema option is availabe' , function ( ) {
You can’t perform that action at this time.
0 commit comments