@@ -469,8 +469,10 @@ const compileSchema = (schema, root, opts, scope, basePathRoot = '') => {
469
469
const nexthistory = ( ) => [ ...history , { stat, prop : current } ]
470
470
// Can not be used before undefined check! The one performed by present()
471
471
const rule = ( ...args ) => visit ( errors , nexthistory ( ) , ...args ) . stat
472
- const subrule = ( suberr , ...args ) => {
473
- if ( args [ 0 ] === current ) {
472
+ const subrule = ( ...args ) => subruleImpl ( false , ...args )
473
+ const subruleSub = ( ...args ) => subruleImpl ( true , ...args ) . sub
474
+ const subruleImpl = ( noDelta , suberr , ...args ) => {
475
+ if ( args [ 0 ] === current || noDelta ) {
474
476
const constval = constantValue ( args [ 1 ] )
475
477
if ( constval === true ) return { sub : format ( 'true' ) , delta : { } }
476
478
if ( constval === false ) return { sub : format ( 'false' ) , delta : { type : [ ] } }
@@ -894,7 +896,7 @@ const compileSchema = (schema, root, opts, scope, basePathRoot = '') => {
894
896
895
897
const suberr = suberror ( )
896
898
iterate ( ( prop , evaluate ) => {
897
- const { sub } = subrule ( suberr , prop , node . contains , subPath ( 'contains' ) )
899
+ const sub = subruleSub ( suberr , prop , node . contains , subPath ( 'contains' ) )
898
900
fun . if ( sub , ( ) => {
899
901
fun . write ( '%s++' , passes )
900
902
if ( getMeta ( ) . containsEvaluates ) {
@@ -914,7 +916,7 @@ const compileSchema = (schema, root, opts, scope, basePathRoot = '') => {
914
916
}
915
917
916
918
const checkGeneric = ( ) => {
917
- handle ( 'not' , [ 'object' , 'boolean' ] , ( not ) => subrule ( null , current , not , subPath ( 'not' ) ) . sub )
919
+ handle ( 'not' , [ 'object' , 'boolean' ] , ( not ) => subruleSub ( null , current , not , subPath ( 'not' ) ) )
918
920
if ( node . not ) uncertain ( 'not' )
919
921
920
922
const thenOrElse = node . then || node . then === false || node . else || node . else === false
0 commit comments