Starcounter-Jack / JSON-Patch

Lean and mean Javascript implementation of the JSON-Patch standard (RFC 6902). Update JSON documents using delta patches.
MIT License
1.78k stars 215 forks source link

Error index always 0? #297

Open ncamomot opened 2 years ago

ncamomot commented 2 years ago
const validationError = jsonpatch.validate([
  { op: 'replace', path: '/firstName', value: 'first' },
 // middleName does not exist
 { op: 'remove', path: '/middleName', value: 'middle' }
], 
{ firstName: 'first', lastName: 'last' })

validationError.index // = 0

I was expecting it as 1. I am wrong to expect that?

beam-bence commented 1 year ago

This issue may be related to https://github.com/Starcounter-Jack/JSON-Patch/issues/300 Constant 0 is passed as the index parameter. Here's the suggested fix and pull request https://github.com/Starcounter-Jack/JSON-Patch/pull/301