@@ -2486,7 +2486,7 @@ function _getPathsToValidate(doc) {
24862486 const fullPathToSubdoc = subdoc . $__fullPathWithIndexes ( ) ;
24872487
24882488 for ( const p of paths ) {
2489- if ( p === null || p . startsWith ( fullPathToSubdoc + '.' ) ) {
2489+ if ( p == null || p . startsWith ( fullPathToSubdoc + '.' ) ) {
24902490 paths . delete ( p ) ;
24912491 }
24922492 }
@@ -2507,6 +2507,14 @@ function _getPathsToValidate(doc) {
25072507 continue ;
25082508 }
25092509
2510+ if ( _pathType . $isMongooseDocumentArray ) {
2511+ for ( const p of paths ) {
2512+ if ( p == null || p . startsWith ( _pathType . path + '.' ) ) {
2513+ paths . delete ( p ) ;
2514+ }
2515+ }
2516+ }
2517+
25102518 // Optimization: if primitive path with no validators, or array of primitives
25112519 // with no validators, skip validating this path entirely.
25122520 if ( ! _pathType . caster && _pathType . validators . length === 0 ) {
@@ -3145,16 +3153,15 @@ Document.prototype.$__reset = function reset() {
31453153 if ( subdoc . $isDocumentArrayElement ) {
31463154 if ( ! resetArrays . has ( subdoc . parentArray ( ) ) ) {
31473155 const array = subdoc . parentArray ( ) ;
3148- // Mark path to array as init for gh-6818
3149- this . $__ . activePaths . init ( fullPathWithIndexes . replace ( / \. \d + $ / , '' ) . slice ( - subdoc . $basePath - 1 ) ) ;
3156+ this . $__ . activePaths . clearPath ( fullPathWithIndexes . replace ( / \. \d + $ / , '' ) . slice ( - subdoc . $basePath - 1 ) ) ;
31503157 array [ arrayAtomicsBackupSymbol ] = array [ arrayAtomicsSymbol ] ;
31513158 array [ arrayAtomicsSymbol ] = { } ;
31523159
31533160 resetArrays . add ( array ) ;
31543161 }
31553162 } else {
31563163 if ( subdoc . $parent ( ) === this ) {
3157- this . $__ . activePaths . init ( subdoc . $basePath ) ;
3164+ this . $__ . activePaths . clearPath ( subdoc . $basePath ) ;
31583165 } else if ( subdoc . $parent ( ) != null && subdoc . $parent ( ) . $isSubdocument ) {
31593166 // If map path underneath subdocument, may end up with a case where
31603167 // map path is modified but parent still needs to be reset. See gh-10295
0 commit comments