From 683c0b6574fd68c94533b8c01da439cec4f455ee Mon Sep 17 00:00:00 2001 From: Jonas Finnemann Jensen Date: Fri, 22 May 2015 11:23:49 -0700 Subject: [PATCH 1/2] Use require v4 in examples --- README.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 47350d8..e617f8a 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,13 @@ Simply pass a schema to compile it var validator = require('is-my-json-valid') var validate = validator({ - required: true, type: 'object', properties: { hello: { - required: true, type: 'string' } - } + }, + required: ['hello'] }) console.log('should be valid', validate({hello: 'world'})) @@ -58,7 +57,6 @@ If you want to add your own custom formats pass them as the formats options to t ``` js var validate = validator({ type: 'string', - required: true, format: 'only-a' }, { formats: { @@ -76,7 +74,6 @@ You can pass in external schemas that you reference using the `$ref` attribute a ``` js var ext = { - required: true, type: 'string' } @@ -97,11 +94,11 @@ is-my-json-valid supports filtering away properties not in the schema ``` js var filter = validator.filter({ - required: true, type: 'object', properties: { - hello: {type: 'string', required: true} + hello: {type: 'string'} }, + required: ['hello'], additionalProperties: false }) @@ -115,14 +112,13 @@ is-my-json-valid outputs the value causing an error when verbose is set to true ``` js var validate = validator({ - required: true, type: 'object', properties: { hello: { - required: true, type: 'string' } - } + }, + required: ['hello'] }, { verbose: true }) From 5eeb5c82bd9a1c6c16cb935be0350f61111db39b Mon Sep 17 00:00:00 2001 From: Jonas Finnemann Jensen Date: Fri, 22 May 2015 11:25:36 -0700 Subject: [PATCH 2/2] Make tests not rely on undefined (it's invalid JSON) --- test/misc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/misc.js b/test/misc.js index b5109e5..8e660a2 100644 --- a/test/misc.js +++ b/test/misc.js @@ -15,7 +15,7 @@ tape('simple', function(t) { var validate = validator(schema) t.ok(validate({hello: 'world'}), 'should be valid') - t.notOk(validate(), 'should be invalid') + t.notOk(validate(null), 'should be invalid') t.notOk(validate({}), 'should be invalid') t.end() }) @@ -111,7 +111,7 @@ tape('array', function(t) { }) t.notOk(validate({}), 'wrong type') - t.notOk(validate(), 'is required') + t.notOk(validate(null), 'is required') t.ok(validate(['test'])) t.end() })