var _schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://jsonschema.net",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/0",
"type": "object",
"properties": {
"_id": {
"id": "http://jsonschema.net/0/_id",
"type": "number"
},
"index": {
"id": "http://jsonschema.net/0/index",
"type": "integer"
},
"guid": {
"id": "http://jsonschema.net/0/guid",
"type": "number"
},
"isActive": {
"id": "http://jsonschema.net/0/isActive",
"type": "boolean"
},
"balance": {
"id": "http://jsonschema.net/0/balance",
"type": "string"
},
"picture": {
"id": "http://jsonschema.net/0/picture",
"type": "string"
},
"age": {
"id": "http://jsonschema.net/0/age",
"type": "integer"
},
"eyeColor": {
"id": "http://jsonschema.net/0/eyeColor",
"type": "string"
},
"name": {
"id": "http://jsonschema.net/0/name",
"type": "string"
},
"gender": {
"id": "http://jsonschema.net/0/gender",
"type": "string"
},
"company": {
"id": "http://jsonschema.net/0/company",
"type": "string"
},
"email": {
"id": "http://jsonschema.net/0/email",
"type": "string"
},
"phone": {
"id": "http://jsonschema.net/0/phone",
"type": "string"
},
"address": {
"id": "http://jsonschema.net/0/address",
"type": "string"
},
"about": {
"id": "http://jsonschema.net/0/about",
"type": "string"
},
"registered": {
"id": "http://jsonschema.net/0/registered",
"type": "string"
},
"latitude": {
"id": "http://jsonschema.net/0/latitude",
"type": "number"
},
"longitude": {
"id": "http://jsonschema.net/0/longitude",
"type": "number"
},
"tags": {
"id": "http://jsonschema.net/0/tags",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/0/tags/0",
"type": "string"
},
{
"id": "http://jsonschema.net/0/tags/1",
"type": "string"
},
{
"id": "http://jsonschema.net/0/tags/2",
"type": "string"
},
{
"id": "http://jsonschema.net/0/tags/3",
"type": "string"
},
{
"id": "http://jsonschema.net/0/tags/4",
"type": "string"
},
{
"id": "http://jsonschema.net/0/tags/5",
"type": "string"
},
{
"id": "http://jsonschema.net/0/tags/6",
"type": "string"
}
]
},
"friends": {
"id": "http://jsonschema.net/0/friends",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/0/friends/0",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/0/friends/0/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/0/friends/0/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/0/friends/1",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/0/friends/1/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/0/friends/1/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/0/friends/2",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/0/friends/2/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/0/friends/2/name",
"type": "string"
}
}
}
]
},
"greeting": {
"id": "http://jsonschema.net/0/greeting",
"type": "string"
},
"favoriteFruit": {
"id": "http://jsonschema.net/0/favoriteFruit",
"type": "string"
}
},
"required": [
"_id",
"index",
"guid",
"isActive",
"balance",
"picture",
"age",
"eyeColor",
"name",
"gender",
"company",
"email",
"phone",
"address",
"about",
"registered",
"latitude",
"longitude",
"tags",
"friends",
"greeting",
"favoriteFruit"
]
},
{
"id": "http://jsonschema.net/1",
"type": "object",
"properties": {
"_id": {
"id": "http://jsonschema.net/1/_id",
"type": "string"
},
"index": {
"id": "http://jsonschema.net/1/index",
"type": "integer"
},
"guid": {
"id": "http://jsonschema.net/1/guid",
"type": "string"
},
"isActive": {
"id": "http://jsonschema.net/1/isActive",
"type": "boolean"
},
"balance": {
"id": "http://jsonschema.net/1/balance",
"type": "string"
},
"picture": {
"id": "http://jsonschema.net/1/picture",
"type": "string"
},
"age": {
"id": "http://jsonschema.net/1/age",
"type": "integer"
},
"eyeColor": {
"id": "http://jsonschema.net/1/eyeColor",
"type": "string"
},
"name": {
"id": "http://jsonschema.net/1/name",
"type": "string"
},
"gender": {
"id": "http://jsonschema.net/1/gender",
"type": "string"
},
"company": {
"id": "http://jsonschema.net/1/company",
"type": "string"
},
"email": {
"id": "http://jsonschema.net/1/email",
"type": "string"
},
"phone": {
"id": "http://jsonschema.net/1/phone",
"type": "string"
},
"address": {
"id": "http://jsonschema.net/1/address",
"type": "string"
},
"about": {
"id": "http://jsonschema.net/1/about",
"type": "string"
},
"registered": {
"id": "http://jsonschema.net/1/registered",
"type": "string"
},
"latitude": {
"id": "http://jsonschema.net/1/latitude",
"type": "number"
},
"longitude": {
"id": "http://jsonschema.net/1/longitude",
"type": "number"
},
"tags": {
"id": "http://jsonschema.net/1/tags",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/1/tags/0",
"type": "string"
},
{
"id": "http://jsonschema.net/1/tags/1",
"type": "string"
},
{
"id": "http://jsonschema.net/1/tags/2",
"type": "string"
},
{
"id": "http://jsonschema.net/1/tags/3",
"type": "string"
},
{
"id": "http://jsonschema.net/1/tags/4",
"type": "string"
},
{
"id": "http://jsonschema.net/1/tags/5",
"type": "string"
},
{
"id": "http://jsonschema.net/1/tags/6",
"type": "string"
}
]
},
"friends": {
"id": "http://jsonschema.net/1/friends",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/1/friends/0",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/1/friends/0/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/1/friends/0/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/1/friends/1",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/1/friends/1/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/1/friends/1/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/1/friends/2",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/1/friends/2/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/1/friends/2/name",
"type": "string"
}
}
}
]
},
"greeting": {
"id": "http://jsonschema.net/1/greeting",
"type": "string"
},
"favoriteFruit": {
"id": "http://jsonschema.net/1/favoriteFruit",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/2",
"type": "object",
"properties": {
"_id": {
"id": "http://jsonschema.net/2/_id",
"type": "string"
},
"index": {
"id": "http://jsonschema.net/2/index",
"type": "integer"
},
"guid": {
"id": "http://jsonschema.net/2/guid",
"type": "string"
},
"isActive": {
"id": "http://jsonschema.net/2/isActive",
"type": "boolean"
},
"balance": {
"id": "http://jsonschema.net/2/balance",
"type": "string"
},
"picture": {
"id": "http://jsonschema.net/2/picture",
"type": "string"
},
"age": {
"id": "http://jsonschema.net/2/age",
"type": "integer"
},
"eyeColor": {
"id": "http://jsonschema.net/2/eyeColor",
"type": "string"
},
"name": {
"id": "http://jsonschema.net/2/name",
"type": "string"
},
"gender": {
"id": "http://jsonschema.net/2/gender",
"type": "string"
},
"company": {
"id": "http://jsonschema.net/2/company",
"type": "string"
},
"email": {
"id": "http://jsonschema.net/2/email",
"type": "string"
},
"phone": {
"id": "http://jsonschema.net/2/phone",
"type": "string"
},
"address": {
"id": "http://jsonschema.net/2/address",
"type": "string"
},
"about": {
"id": "http://jsonschema.net/2/about",
"type": "string"
},
"registered": {
"id": "http://jsonschema.net/2/registered",
"type": "string"
},
"latitude": {
"id": "http://jsonschema.net/2/latitude",
"type": "number"
},
"longitude": {
"id": "http://jsonschema.net/2/longitude",
"type": "number"
},
"tags": {
"id": "http://jsonschema.net/2/tags",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/2/tags/0",
"type": "string"
},
{
"id": "http://jsonschema.net/2/tags/1",
"type": "string"
},
{
"id": "http://jsonschema.net/2/tags/2",
"type": "string"
},
{
"id": "http://jsonschema.net/2/tags/3",
"type": "string"
},
{
"id": "http://jsonschema.net/2/tags/4",
"type": "string"
},
{
"id": "http://jsonschema.net/2/tags/5",
"type": "string"
},
{
"id": "http://jsonschema.net/2/tags/6",
"type": "string"
}
]
},
"friends": {
"id": "http://jsonschema.net/2/friends",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/2/friends/0",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/2/friends/0/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/2/friends/0/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/2/friends/1",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/2/friends/1/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/2/friends/1/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/2/friends/2",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/2/friends/2/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/2/friends/2/name",
"type": "string"
}
}
}
]
},
"greeting": {
"id": "http://jsonschema.net/2/greeting",
"type": "string"
},
"favoriteFruit": {
"id": "http://jsonschema.net/2/favoriteFruit",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/3",
"type": "object",
"properties": {
"_id": {
"id": "http://jsonschema.net/3/_id",
"type": "string"
},
"index": {
"id": "http://jsonschema.net/3/index",
"type": "integer"
},
"guid": {
"id": "http://jsonschema.net/3/guid",
"type": "string"
},
"isActive": {
"id": "http://jsonschema.net/3/isActive",
"type": "boolean"
},
"balance": {
"id": "http://jsonschema.net/3/balance",
"type": "string"
},
"picture": {
"id": "http://jsonschema.net/3/picture",
"type": "string"
},
"age": {
"id": "http://jsonschema.net/3/age",
"type": "integer"
},
"eyeColor": {
"id": "http://jsonschema.net/3/eyeColor",
"type": "string"
},
"name": {
"id": "http://jsonschema.net/3/name",
"type": "string"
},
"gender": {
"id": "http://jsonschema.net/3/gender",
"type": "string"
},
"company": {
"id": "http://jsonschema.net/3/company",
"type": "string"
},
"email": {
"id": "http://jsonschema.net/3/email",
"type": "string"
},
"phone": {
"id": "http://jsonschema.net/3/phone",
"type": "string"
},
"address": {
"id": "http://jsonschema.net/3/address",
"type": "string"
},
"about": {
"id": "http://jsonschema.net/3/about",
"type": "string"
},
"registered": {
"id": "http://jsonschema.net/3/registered",
"type": "string"
},
"latitude": {
"id": "http://jsonschema.net/3/latitude",
"type": "number"
},
"longitude": {
"id": "http://jsonschema.net/3/longitude",
"type": "number"
},
"tags": {
"id": "http://jsonschema.net/3/tags",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/3/tags/0",
"type": "string"
},
{
"id": "http://jsonschema.net/3/tags/1",
"type": "string"
},
{
"id": "http://jsonschema.net/3/tags/2",
"type": "string"
},
{
"id": "http://jsonschema.net/3/tags/3",
"type": "string"
},
{
"id": "http://jsonschema.net/3/tags/4",
"type": "string"
},
{
"id": "http://jsonschema.net/3/tags/5",
"type": "string"
},
{
"id": "http://jsonschema.net/3/tags/6",
"type": "string"
}
]
},
"friends": {
"id": "http://jsonschema.net/3/friends",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/3/friends/0",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/3/friends/0/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/3/friends/0/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/3/friends/1",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/3/friends/1/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/3/friends/1/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/3/friends/2",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/3/friends/2/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/3/friends/2/name",
"type": "string"
}
}
}
]
},
"greeting": {
"id": "http://jsonschema.net/3/greeting",
"type": "string"
},
"favoriteFruit": {
"id": "http://jsonschema.net/3/favoriteFruit",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/4",
"type": "object",
"properties": {
"_id": {
"id": "http://jsonschema.net/4/_id",
"type": "string"
},
"index": {
"id": "http://jsonschema.net/4/index",
"type": "integer"
},
"guid": {
"id": "http://jsonschema.net/4/guid",
"type": "string"
},
"isActive": {
"id": "http://jsonschema.net/4/isActive",
"type": "boolean"
},
"balance": {
"id": "http://jsonschema.net/4/balance",
"type": "string"
},
"picture": {
"id": "http://jsonschema.net/4/picture",
"type": "string"
},
"age": {
"id": "http://jsonschema.net/4/age",
"type": "integer"
},
"eyeColor": {
"id": "http://jsonschema.net/4/eyeColor",
"type": "string"
},
"name": {
"id": "http://jsonschema.net/4/name",
"type": "string"
},
"gender": {
"id": "http://jsonschema.net/4/gender",
"type": "string"
},
"company": {
"id": "http://jsonschema.net/4/company",
"type": "string"
},
"email": {
"id": "http://jsonschema.net/4/email",
"type": "string"
},
"phone": {
"id": "http://jsonschema.net/4/phone",
"type": "string"
},
"address": {
"id": "http://jsonschema.net/4/address",
"type": "string"
},
"about": {
"id": "http://jsonschema.net/4/about",
"type": "string"
},
"registered": {
"id": "http://jsonschema.net/4/registered",
"type": "string"
},
"latitude": {
"id": "http://jsonschema.net/4/latitude",
"type": "number"
},
"longitude": {
"id": "http://jsonschema.net/4/longitude",
"type": "number"
},
"tags": {
"id": "http://jsonschema.net/4/tags",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/4/tags/0",
"type": "string"
},
{
"id": "http://jsonschema.net/4/tags/1",
"type": "string"
},
{
"id": "http://jsonschema.net/4/tags/2",
"type": "string"
},
{
"id": "http://jsonschema.net/4/tags/3",
"type": "string"
},
{
"id": "http://jsonschema.net/4/tags/4",
"type": "string"
},
{
"id": "http://jsonschema.net/4/tags/5",
"type": "string"
},
{
"id": "http://jsonschema.net/4/tags/6",
"type": "string"
}
]
},
"friends": {
"id": "http://jsonschema.net/4/friends",
"type": "array",
"items": [
{
"id": "http://jsonschema.net/4/friends/0",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/4/friends/0/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/4/friends/0/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/4/friends/1",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/4/friends/1/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/4/friends/1/name",
"type": "string"
}
}
},
{
"id": "http://jsonschema.net/4/friends/2",
"type": "object",
"properties": {
"id": {
"id": "http://jsonschema.net/4/friends/2/id",
"type": "integer"
},
"name": {
"id": "http://jsonschema.net/4/friends/2/name",
"type": "string"
}
}
}
]
},
"greeting": {
"id": "http://jsonschema.net/4/greeting",
"type": "string"
},
"favoriteFruit": {
"id": "http://jsonschema.net/4/favoriteFruit",
"type": "string"
}
}
}
],
"required": [
"0",
"1",
"2",
"3",
"4"
]
};
var obj = [
{
"_id": "556560b766605c41d66d5910",
"index": 0,
"guid": "b0057de2-b2b9-4f5e-8a10-3259e54ac5ae",
"isActive": true,
"balance": "$3,798.63",
"picture": "http://placehold.it/32x32",
"age": 40,
"eyeColor": "blue",
"name": "Shawn Evans",
"gender": "female",
"company": "FOSSIEL",
"email": "[email protected]",
"phone": "+1 (956) 479-2930",
"address": "879 Meserole Avenue, Norvelt, Indiana, 428",
"about": "Cillum qui dolor quis sunt do aliquip aliqua pariatur ut laborum. Anim sit dolor tempor fugiat mollit nostrud veniam ad velit elit. Ea commodo ad incididunt voluptate.\r\n",
"registered": "2014-04-20T14:33:16 -04:00",
"latitude": -40.01082,
"longitude": -118.957523,
"tags": [
"consequat",
"ex",
"non",
"irure",
"id",
"sint",
"eu"
],
"friends": [
{
"id": 0,
"name": "Keisha Duncan"
},
{
"id": 1,
"name": "Blanca Cantu"
},
{
"id": 2,
"name": "Deidre Cotton"
}
],
"greeting": "Hello, Shawn Evans! You have 1 unread messages.",
"favoriteFruit": "apple"
},
{
"_id": "556560b74f4b9e71e73d7856",
"index": 1,
"guid": "92c770b3-80b8-4bdc-aad4-9a2330bb0a23",
"isActive": true,
"balance": "$1,315.39",
"picture": "http://placehold.it/32x32",
"age": 29,
"eyeColor": "brown",
"name": "Lucas Pacheco",
"gender": "male",
"company": "MOTOVATE",
"email": "[email protected]",
"phone": "+1 (988) 541-2454",
"address": "589 Gunther Place, Carrsville, Washington, 520",
"about": "Deserunt cillum magna ut irure nostrud dolor sunt excepteur anim enim. Qui dolore fugiat nulla velit velit fugiat proident nostrud nulla exercitation non. Tempor tempor et consequat consequat aute eiusmod commodo veniam ad veniam laborum.\r\n",
"registered": "2015-04-24T03:13:02 -04:00",
"latitude": -45.336031,
"longitude": 150.45798,
"tags": [
"id",
"laboris",
"ea",
"officia",
"laborum",
"minim",
"labore"
],
"friends": [
{
"id": 0,
"name": "Jackson Charles"
},
{
"id": 1,
"name": "Burt Cline"
},
{
"id": 2,
"name": "Weiss Randall"
}
],
"greeting": "Hello, Lucas Pacheco! You have 10 unread messages.",
"favoriteFruit": "strawberry"
},
{
"_id": "556560b7a46b9075e0196ceb",
"index": 2,
"guid": "ee7bd878-7759-4805-93ad-dff5358c9127",
"isActive": true,
"balance": "$2,162.78",
"picture": "http://placehold.it/32x32",
"age": 28,
"eyeColor": "green",
"name": "Haynes Mccarthy",
"gender": "male",
"company": "DUOFLEX",
"email": "[email protected]",
"phone": "+1 (982) 465-2986",
"address": "964 Amity Street, Clinton, Montana, 3904",
"about": "Nostrud excepteur exercitation aliquip deserunt pariatur enim amet aute qui. Aliquip est dolore dolor deserunt irure laborum cillum dolor. Cillum id est aliquip aliquip sunt anim tempor officia est. Amet Lorem consectetur sint nulla incididunt est occaecat. Do aute enim est laboris laboris cillum culpa ea. Nulla velit id labore aliquip voluptate ex.\r\n",
"registered": "2014-07-31T00:55:13 -04:00",
"latitude": -75.735289,
"longitude": 104.668396,
"tags": [
"anim",
"do",
"ea",
"reprehenderit",
"laboris",
"commodo",
"ea"
],
"friends": [
{
"id": 0,
"name": "Bates Mayo"
},
{
"id": 1,
"name": "Koch Cardenas"
},
{
"id": 2,
"name": "Harrison Bishop"
}
],
"greeting": "Hello, Haynes Mccarthy! You have 7 unread messages.",
"favoriteFruit": "apple"
},
{
"_id": "556560b75909befce91e6e1e",
"index": 3,
"guid": "c6606f4c-c424-4614-9ccf-eb24012f6469",
"isActive": true,
"balance": "$3,982.88",
"picture": "http://placehold.it/32x32",
"age": 21,
"eyeColor": "brown",
"name": "Stephens Mercer",
"gender": "male",
"company": "ZOID",
"email": "[email protected]",
"phone": "+1 (854) 545-3206",
"address": "332 Autumn Avenue, Makena, New Mexico, 2363",
"about": "Fugiat reprehenderit consectetur ullamco deserunt. Mollit amet adipisicing sunt voluptate mollit elit non Lorem ut excepteur exercitation minim magna. Esse consectetur adipisicing magna aliqua exercitation anim quis officia et commodo.\r\n",
"registered": "2014-01-20T15:13:25 -04:00",
"latitude": -48.455294,
"longitude": -129.759485,
"tags": [
"dolore",
"id",
"cupidatat",
"qui",
"deserunt",
"ea",
"pariatur"
],
"friends": [
{
"id": 0,
"name": "Bridgette Craig"
},
{
"id": 1,
"name": "Maryellen Saunders"
},
{
"id": 2,
"name": "Mclaughlin Oneal"
}
],
"greeting": "Hello, Stephens Mercer! You have 4 unread messages.",
"favoriteFruit": "apple"
},
{
"_id": "556560b7154ca98f4e1dec03",
"index": 4,
"guid": "161c6649-9dc8-4e19-8f61-a99f9ffa0543",
"isActive": true,
"balance": "$2,613.57",
"picture": "http://placehold.it/32x32",
"age": 30,
"eyeColor": "green",
"name": "Rosemarie Levy",
"gender": "female",
"company": "NORSUL",
"email": "[email protected]",
"phone": "+1 (837) 545-2870",
"address": "803 Cumberland Street, Loveland, Colorado, 8884",
"about": "Sit anim est non elit aliquip Lorem enim mollit id exercitation culpa quis. Do irure dolor laborum et consequat ullamco. Quis culpa fugiat do occaecat adipisicing ipsum labore mollit. Ad cillum id voluptate consectetur incididunt dolore non laboris. Dolor exercitation ad exercitation et.\r\n",
"registered": "2014-11-21T22:37:15 -04:00",
"latitude": 29.446521,
"longitude": 69.509939,
"tags": [
"deserunt",
"reprehenderit",
"qui",
"tempor",
"est",
"enim",
"non"
],
"friends": [
{
"id": 0,
"name": "Cathleen Griffin"
},
{
"id": 1,
"name": "Beulah Hester"
},
{
"id": 2,
"name": "Staci Carney"
}
],
"greeting": "Hello, Rosemarie Levy! You have 10 unread messages.",
"favoriteFruit": "strawberry"
}
];
var j = require('is-my-json-valid');
var validate = j(_schema, { copy:false });
var res = validate(obj);
console.log(res);
As you can see in the schema the property "guid" must be a number, but in the object this property is a string. The result of validation is TRUE. That's wrong!