|
8 سال پیش | |
---|---|---|
.. | ||
bin | 8 سال پیش | |
lib | 8 سال پیش | |
LICENSE | 8 سال پیش | |
README.md | 8 سال پیش | |
package.json | 8 سال پیش |
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.
data: Object
(Required)
a full HAR object
validate(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a log object
validate.log(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a cache object
validate.cache(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a "beforeRequest" or "afterRequest" objects
validate.cacheEntry(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a content object
validate.content(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a cookie object
validate.cookie(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a creator object
validate.creator(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
an entry object
validate.entry(data)
.then(data => console.log('horray!'))
.catch(console.error)
alias of Validate(data)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a page object
validate.page(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a pageTimings object
validate.pageTimings(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a postData object
validate.postData(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a record object
validate.record(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a request object
validate.request(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a response object
validate.cacheEntry(data)
.then(data => console.log('horray!'))
.catch(console.error)
Returns a promise that resolves to the valid object.
data: Object
(Required)
a timings object
validate.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.