1+ import  toPath  from  'lodash.topath' ; 
12import  { validate  as  jsonValidate }  from  "jsonschema" ; 
23
34import  { isObject ,  mergeObjects }  from  "./utils" ; 
45
5- 
6- const  RE_ERROR_ARRAY_PATH  =  / \[ \d + ] / g; 
7- 
8- function  errorPropertyToPath ( property )  { 
9-  // Parse array indices, eg. "instance.level1.level2[2].level3" 
10-  // => ["instance", "level1", "level2", 2, "level3"] 
11-  return  property . split ( "." ) . reduce ( ( path ,  node )  =>  { 
12-  const  match  =  node . match ( RE_ERROR_ARRAY_PATH ) ; 
13-  if  ( match )  { 
14-  const  nodeName  =  node . slice ( 0 ,  node . indexOf ( "[" ) ) ; 
15-  const  indices  =  match . map ( str  =>  parseInt ( str . slice ( 1 ,  - 1 ) ,  10 ) ) ; 
16-  path  =  path . concat ( nodeName ,  indices ) ; 
17-  }  else  { 
18-  path . push ( node ) ; 
19-  } 
20-  return  path ; 
21-  } ,  [ ] ) ; 
22- } 
23- 
246function  toErrorSchema ( errors )  { 
257 // Transforms a jsonschema validation errors list: 
268 // [ 
@@ -42,7 +24,7 @@ function toErrorSchema(errors) {
4224 } 
4325 return  errors . reduce ( ( errorSchema ,  error )  =>  { 
4426 const  { property,  message}  =  error ; 
45-  const  path  =  errorPropertyToPath ( property ) ; 
27+  const  path  =  toPath ( property ) ; 
4628 let  parent  =  errorSchema ; 
4729 for  ( const  segment  of  path . slice ( 1 ) )  { 
4830 if  ( ! ( segment  in  parent ) )  { 
0 commit comments