@@ -58,6 +58,7 @@ export class SchemaValidationException extends BaseException {
58
58
) {
59
59
if ( ! errors || errors . length === 0 ) {
60
60
super ( 'Schema validation failed.' ) ;
61
+ this . errors = [ ] ;
61
62
62
63
return ;
63
64
}
@@ -194,7 +195,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
194
195
195
196
protected _resolver (
196
197
ref : string ,
197
- validate : ajv . ValidateFunction ,
198
+ validate ? : ajv . ValidateFunction ,
198
199
) : { context ?: ajv . ValidateFunction , schema ?: JsonObject } {
199
200
if ( ! validate || ! validate . refs || ! validate . refVal || ! ref ) {
200
201
return { } ;
@@ -396,10 +397,10 @@ export class CoreSchemaRegistry implements SchemaRegistry {
396
397
switchMap ( updatedData => {
397
398
const result = validate . call ( validationContext , updatedData ) ;
398
399
399
- return typeof result == 'boolean'
400
+ return typeof result === 'boolean'
400
401
? of ( [ updatedData , result ] )
401
402
: from ( ( result as Promise < boolean > )
402
- . then ( r => [ updatedData , true ] )
403
+ . then ( ( ) => [ updatedData , true ] )
403
404
. catch ( ( err : Error | AjvValidationError ) => {
404
405
if ( ( err as AjvValidationError ) . ajv ) {
405
406
validate . errors = ( err as AjvValidationError ) . errors ;
@@ -410,7 +411,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
410
411
return Promise . reject ( err ) ;
411
412
} ) ) ;
412
413
} ) ,
413
- switchMap ( ( [ data , valid ] : [ JsonValue , boolean ] ) => {
414
+ switchMap ( ( [ data , valid ] ) => {
414
415
if ( valid ) {
415
416
let result = of ( data ) ;
416
417
@@ -430,7 +431,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
430
431
return of ( [ data , valid ] ) ;
431
432
}
432
433
} ) ,
433
- map ( ( [ data , valid ] : [ JsonValue , boolean ] ) => {
434
+ map ( ( [ data , valid ] ) => {
434
435
if ( valid ) {
435
436
return { data, success : true } as SchemaValidatorResult ;
436
437
}
@@ -519,7 +520,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
519
520
this . _ajv . addKeyword ( 'x-prompt' , {
520
521
errors : false ,
521
522
valid : true ,
522
- compile : ( schema , parentSchema : JsonObject , it ) => {
523
+ compile : ( schema , parentSchema , it ) => {
523
524
const compilationSchemInfo = this . _currentCompilationSchemaInfo ;
524
525
if ( ! compilationSchemInfo ) {
525
526
return ( ) => true ;
@@ -540,17 +541,17 @@ export class CoreSchemaRegistry implements SchemaRegistry {
540
541
items = schema . items ;
541
542
}
542
543
543
- const propertyTypes = getTypesOfSchema ( parentSchema ) ;
544
+ const propertyTypes = getTypesOfSchema ( parentSchema as JsonObject ) ;
544
545
if ( ! type ) {
545
546
if ( propertyTypes . size === 1 && propertyTypes . has ( 'boolean' ) ) {
546
547
type = 'confirmation' ;
547
- } else if ( Array . isArray ( parentSchema . enum ) ) {
548
+ } else if ( Array . isArray ( ( parentSchema as JsonObject ) . enum ) ) {
548
549
type = 'list' ;
549
550
} else if (
550
551
propertyTypes . size === 1 &&
551
552
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 )
554
555
) {
555
556
type = 'list' ;
556
557
} else {
@@ -566,8 +567,8 @@ export class CoreSchemaRegistry implements SchemaRegistry {
566
567
: schema . multiselect ;
567
568
568
569
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 ;
571
572
if ( ! items && Array . isArray ( enumValues ) ) {
572
573
items = [ ] ;
573
574
for ( const value of enumValues ) {
@@ -590,11 +591,11 @@ export class CoreSchemaRegistry implements SchemaRegistry {
590
591
items,
591
592
multiselect,
592
593
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 )
596
597
? undefined
597
- : parentSchema . default as string [ ] ,
598
+ : ( parentSchema as JsonObject ) . default as string [ ] ,
598
599
async validator ( data : JsonValue ) {
599
600
try {
600
601
return await it . self . validate ( parentSchema , data ) ;
0 commit comments