@@ -355,6 +355,35 @@ export class CoreSchemaRegistry implements SchemaRegistry {
355
355
updateData ,
356
356
schemaInfo . smartDefaultRecord ,
357
357
) ) ,
358
+ switchMap ( updatedData => {
359
+ if ( validationOptions . withPrompts === false ) {
360
+ return of ( updatedData ) ;
361
+ }
362
+
363
+ const visitor : JsonVisitor = ( value , pointer ) => {
364
+ if ( value !== undefined ) {
365
+ validationContext . promptFieldsWithValue . add ( pointer ) ;
366
+ }
367
+
368
+ return value ;
369
+ } ;
370
+
371
+ return visitJson ( updatedData , visitor , schema , this . _resolver , validate ) ;
372
+ } ) ,
373
+ switchMap ( updatedData => {
374
+ if ( validationOptions . withPrompts === false ) {
375
+ return of ( updatedData ) ;
376
+ }
377
+
378
+ const definitions = schemaInfo . promptDefinitions
379
+ . filter ( def => ! validationContext . promptFieldsWithValue . has ( def . id ) ) ;
380
+
381
+ if ( this . _promptProvider && definitions . length > 0 ) {
382
+ return from ( this . _applyPrompts ( updatedData , definitions ) ) ;
383
+ } else {
384
+ return of ( updatedData ) ;
385
+ }
386
+ } ) ,
358
387
switchMap ( updatedData => {
359
388
const result = validate . call ( validationContext , updatedData ) ;
360
389
@@ -372,22 +401,6 @@ export class CoreSchemaRegistry implements SchemaRegistry {
372
401
return Promise . reject ( err ) ;
373
402
} ) ) ;
374
403
} ) ,
375
- switchMap ( ( [ data , valid ] : [ JsonValue , boolean ] ) => {
376
- if ( validationOptions . withPrompts === false ) {
377
- return of ( [ data , valid ] ) ;
378
- }
379
-
380
- const definitions = schemaInfo . promptDefinitions
381
- . filter ( def => ! validationContext . promptFieldsWithValue . has ( def . id ) ) ;
382
-
383
- if ( valid && this . _promptProvider && definitions . length > 0 ) {
384
- return from ( this . _applyPrompts ( data , definitions ) ) . pipe (
385
- map ( data => [ data , valid ] ) ,
386
- ) ;
387
- } else {
388
- return of ( [ data , valid ] ) ;
389
- }
390
- } ) ,
391
404
switchMap ( ( [ data , valid ] : [ JsonValue , boolean ] ) => {
392
405
if ( valid ) {
393
406
let result = of ( data ) ;
@@ -508,7 +521,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
508
521
509
522
// tslint:disable-next-line:no-any
510
523
const pathArray = ( ( it as any ) . dataPathArr as string [ ] ) . slice ( 1 , it . dataLevel + 1 ) ;
511
- const path = pathArray . join ( '/' ) ;
524
+ const path = '/' + pathArray . map ( p => p . replace ( / ^ \' / , '' ) . replace ( / \' $ / , '' ) ) . join ( '/' ) ;
512
525
513
526
let type : string | undefined ;
514
527
let items : Array < string | { label : string , value : string | number | boolean } > | undefined ;
@@ -609,9 +622,17 @@ export class CoreSchemaRegistry implements SchemaRegistry {
609
622
return from ( provider ( prompts ) ) . pipe (
610
623
map ( answers => {
611
624
for ( const path in answers ) {
625
+ const pathFragments = path . split ( '/' ) . map ( pf => {
626
+ if ( / ^ \d + $ / . test ( pf ) ) {
627
+ return pf ;
628
+ } else {
629
+ return '\'' + pf + '\'' ;
630
+ }
631
+ } ) ;
632
+
612
633
CoreSchemaRegistry . _set (
613
634
data ,
614
- path . split ( '/' ) ,
635
+ pathFragments . slice ( 1 ) ,
615
636
answers [ path ] as { } ,
616
637
null ,
617
638
undefined ,
0 commit comments