Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'}))
Expand Down Expand Up @@ -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: {
Expand All @@ -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'
}

Expand All @@ -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
})

Expand All @@ -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
})
Expand Down
4 changes: 2 additions & 2 deletions test/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep the previous one as well? would be nice to test both undefined and null

t.notOk(validate({}), 'should be invalid')
t.end()
})
Expand Down Expand Up @@ -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()
})
Expand Down