@@ -355,6 +355,35 @@ export class CoreSchemaRegistry implements SchemaRegistry {
355355 updateData ,
356356 schemaInfo . smartDefaultRecord ,
357357 ) ) ,
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+ } ) ,
358387 switchMap ( updatedData => {
359388 const result = validate . call ( validationContext , updatedData ) ;
360389
@@ -372,22 +401,6 @@ export class CoreSchemaRegistry implements SchemaRegistry {
372401 return Promise . reject ( err ) ;
373402 } ) ) ;
374403 } ) ,
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- } ) ,
391404 switchMap ( ( [ data , valid ] : [ JsonValue , boolean ] ) => {
392405 if ( valid ) {
393406 let result = of ( data ) ;
@@ -508,7 +521,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
508521
509522 // tslint:disable-next-line:no-any
510523 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 ( '/' ) ;
512525
513526 let type : string | undefined ;
514527 let items : Array < string | { label : string , value : string | number | boolean } > | undefined ;
@@ -609,9 +622,17 @@ export class CoreSchemaRegistry implements SchemaRegistry {
609622 return from ( provider ( prompts ) ) . pipe (
610623 map ( answers => {
611624 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+
612633 CoreSchemaRegistry . _set (
613634 data ,
614- path . split ( '/' ) ,
635+ pathFragments . slice ( 1 ) ,
615636 answers [ path ] as { } ,
616637 null ,
617638 undefined ,
0 commit comments