Nicholas 4f3c02d688 Ready to merge into master | 6 vuotta sitten | |
---|---|---|
.. | ||
bin | 6 vuotta sitten | |
lib | 6 vuotta sitten | |
node_modules | 6 vuotta sitten | |
LICENSE | 6 vuotta sitten | |
README.md | 6 vuotta sitten | |
package.json | 6 vuotta sitten |
Extremely fast HTTP Archive (HAR) validator using JSON Schema.
# to use in cli
npm install --global har-validator
# to use as a module
npm install --save har-validator
Usage: har-validator [options] <files ...>
Options:
-h, --help output usage information
-V, --version output the version number
-s, --schema [name] validate schema name (log, request, response, etc ...)
har-validator har.json
har-validator --schema request request.json
Note: as of v2.0.0
this module defaults to Promise based API. For backward comptability with v1.x
an async/callback API is provided
Returns a promise that resolves to the valid object.
Object
(Required)
a full HAR objectvalidate(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a log objectvalidate.log(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a cache objectvalidate.cache(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a "beforeRequest" or "afterRequest" objectsvalidate.cacheEntry(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a content objectvalidate.content(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a cookie objectvalidate.cookie(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a creator objectvalidate.creator(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
an entry objectvalidate.entry(data)
.then(data => console.log('horray!'))
.catch(console.error)
alias of Validate(data)
Returns a promise that resolves to the valid object.
Object
(Required)
a page objectvalidate.page(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a pageTimings objectvalidate.pageTimings(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a postData objectvalidate.postData(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a record objectvalidate.record(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a request objectvalidate.request(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a response objectvalidate.cacheEntry(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
Object
(Required)
a timings objectvalidate.timings(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns
true
orfalse
.
var HAR = require('./har.json');
var validate = require('har-validator/lib/async');
validate(HAR, function (e, valid) {
if (e) console.log(e.errors)
if (valid) console.log('horray!');
});
The async API provides exactly the same methods as the Promise API
Donations are welcome to help support the continuous development of this project.