@@ -58,6 +58,7 @@ export class SchemaValidationException extends BaseException {
5858 ) {
5959 if ( ! errors || errors . length === 0 ) {
6060 super ( 'Schema validation failed.' ) ;
61+ this . errors = [ ] ;
6162
6263 return ;
6364 }
@@ -194,7 +195,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
194195
195196 protected _resolver (
196197 ref : string ,
197- validate : ajv . ValidateFunction ,
198+ validate ? : ajv . ValidateFunction ,
198199 ) : { context ?: ajv . ValidateFunction , schema ?: JsonObject } {
199200 if ( ! validate || ! validate . refs || ! validate . refVal || ! ref ) {
200201 return { } ;
@@ -396,10 +397,10 @@ export class CoreSchemaRegistry implements SchemaRegistry {
396397 switchMap ( updatedData => {
397398 const result = validate . call ( validationContext , updatedData ) ;
398399
399- return typeof result == 'boolean'
400+ return typeof result === 'boolean'
400401 ? of ( [ updatedData , result ] )
401402 : from ( ( result as Promise < boolean > )
402- . then ( r => [ updatedData , true ] )
403+ . then ( ( ) => [ updatedData , true ] )
403404 . catch ( ( err : Error | AjvValidationError ) => {
404405 if ( ( err as AjvValidationError ) . ajv ) {
405406 validate . errors = ( err as AjvValidationError ) . errors ;
@@ -410,7 +411,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
410411 return Promise . reject ( err ) ;
411412 } ) ) ;
412413 } ) ,
413- switchMap ( ( [ data , valid ] : [ JsonValue , boolean ] ) => {
414+ switchMap ( ( [ data , valid ] ) => {
414415 if ( valid ) {
415416 let result = of ( data ) ;
416417
@@ -430,7 +431,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
430431 return of ( [ data , valid ] ) ;
431432 }
432433 } ) ,
433- map ( ( [ data , valid ] : [ JsonValue , boolean ] ) => {
434+ map ( ( [ data , valid ] ) => {
434435 if ( valid ) {
435436 return { data, success : true } as SchemaValidatorResult ;
436437 }
@@ -519,7 +520,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
519520 this . _ajv . addKeyword ( 'x-prompt' , {
520521 errors : false ,
521522 valid : true ,
522- compile : ( schema , parentSchema : JsonObject , it ) => {
523+ compile : ( schema , parentSchema , it ) => {
523524 const compilationSchemInfo = this . _currentCompilationSchemaInfo ;
524525 if ( ! compilationSchemInfo ) {
525526 return ( ) => true ;
@@ -540,17 +541,17 @@ export class CoreSchemaRegistry implements SchemaRegistry {
540541 items = schema . items ;
541542 }
542543
543- const propertyTypes = getTypesOfSchema ( parentSchema ) ;
544+ const propertyTypes = getTypesOfSchema ( parentSchema as JsonObject ) ;
544545 if ( ! type ) {
545546 if ( propertyTypes . size === 1 && propertyTypes . has ( 'boolean' ) ) {
546547 type = 'confirmation' ;
547- } else if ( Array . isArray ( parentSchema . enum ) ) {
548+ } else if ( Array . isArray ( ( parentSchema as JsonObject ) . enum ) ) {
548549 type = 'list' ;
549550 } else if (
550551 propertyTypes . size === 1 &&
551552 propertyTypes . has ( 'array' ) &&
552- parentSchema . items &&
553- Array . isArray ( ( parentSchema . items as JsonObject ) . enum )
553+ ( parentSchema as JsonObject ) . items &&
554+ Array . isArray ( ( ( parentSchema as JsonObject ) . items as JsonObject ) . enum )
554555 ) {
555556 type = 'list' ;
556557 } else {
@@ -566,8 +567,8 @@ export class CoreSchemaRegistry implements SchemaRegistry {
566567 : schema . multiselect ;
567568
568569 const enumValues = multiselect
569- ? parentSchema . items && ( parentSchema . items as JsonObject ) . enum
570- : parentSchema . enum ;
570+ ? ( parentSchema as JsonObject ) . items && ( ( parentSchema as JsonObject ) . items as JsonObject ) . enum
571+ : ( parentSchema as JsonObject ) . enum ;
571572 if ( ! items && Array . isArray ( enumValues ) ) {
572573 items = [ ] ;
573574 for ( const value of enumValues ) {
@@ -590,11 +591,11 @@ export class CoreSchemaRegistry implements SchemaRegistry {
590591 items,
591592 multiselect,
592593 default :
593- typeof parentSchema . default == 'object' &&
594- parentSchema . default !== null &&
595- ! Array . isArray ( parentSchema . default )
594+ typeof ( parentSchema as JsonObject ) . default == 'object' &&
595+ ( parentSchema as JsonObject ) . default !== null &&
596+ ! Array . isArray ( ( parentSchema as JsonObject ) . default )
596597 ? undefined
597- : parentSchema . default as string [ ] ,
598+ : ( parentSchema as JsonObject ) . default as string [ ] ,
598599 async validator ( data : JsonValue ) {
599600 try {
600601 return await it . self . validate ( parentSchema , data ) ;
0 commit comments