bruth / jsonpatch-js

A JavaScript implementation of the JSON Media Type for partial modifications: http://tools.ietf.org/html/rfc6902
http://bruth.github.io/jsonpatch-js
BSD 2-Clause "Simplified" License
181 stars 24 forks source link

Do not correctly validate a JSON Patch document #12

Closed diosney closed 10 years ago

diosney commented 10 years ago

At title says, with 0.4.x (tested with .0 & .1) it fails to validate properly the example document at the end (it don't throw an error).

https://www.npmjs.org/package/jsonpatch it does throw the error, though.

{
    "links": {
        "chains": "http://192.168.56.3:3000/api/services/nat/source/chains/{chains.name}"
    },
    "chains": [
        {
            "type": "source",
            "name": "ifall",
            "description": "",
            "id": "539503ac1d58f1da7c608b26"
        },
        {
            "type": "source",
            "name": "ifall2",
            "description": "",
            "id": "5395055ea3c2d260053d3bfe"
        },
        {
            "name": "ifall4",
            "description": "interfaces",
            "type": "source",
            "interfaces": {
                "out": "eth1"
            },
            "id": "5395098770a129630c1a6ead"
        },
        {
            "description": "",
            "name": "ifall3",
            "type": "source",
            "interfaces": "http://example.com/hamster.png",
            "id": "5395062967350b410a022838"
        }
    ],
    "meta": {
        "chains": {
            "total": 4,
            "limit": 10,
            "offset": 0
        }
    }
}
bruth commented 10 years ago

Hi, 0.4.3 is the latest version. I confirmed using node and the browser that the document above does thrown an error when passed to the JSONPatch constructor.

screen shot 2014-09-23 at 7 09 20 pm

bruth commented 10 years ago

Ah, I just noticed is does not when it is passed to jsonpatch.compile or jsonpatch.apply.

diosney commented 10 years ago

Thanks! Good to know.

bruth commented 10 years ago

Released 0.5.0 with the fix