<commit_before># HAR Validator [![version][npm-version]][npm-url] [![License][npm-license]][license-url]

Extremely fast HTTP Archive ([HAR](http://www.softwareishard.com/blog/har-12-spec/)) validator using JSON Schema.

[![Build Status][travis-image]][travis-url]
[![Downloads][npm-downloads]][npm-url]
[![Dependencies][david-image]][david-url]

## Installation

install from source or through [npm](https://www.npmjs.com/):

```shell
npm install --global har-validator
```

## Usage

### CLI

```
  Usage: har-validator <file ...>

  Options:

    -h, --help                         output usage information
    -V, --version                      output the version number
    -s, --schema [request | response]  validate sub schema
```

###### Example


```shell
har-validator ./path/to/har.json

har-validator --schema ./path/to/request.json
```

### Code

Include the module in your code and use directly or with any of the utility methods to validate sub-schemas:

| method        | description                                                                                               |
| ------------- | --------------------------------------------------------------------------------------------------------- |
| `cache`       | validates a [cache](http://www.softwareishard.com/blog/har-12-spec/#cache) object                         |
| `cacheEntry`  | validates a [beforeRequest | afterRequest](http://www.softwareishard.com/blog/har-12-spec/#cache) objects |
| `content`     | validates a [content](http://www.softwareishard.com/blog/har-12-spec/#content) object                     |
| `cookie`      | validates a [cookie](http://www.softwareishard.com/blog/har-12-spec/#cookie) object                       |
| `creator`     | validates a [creator](http://www.softwareishard.com/blog/har-12-spec/#creator) object                     |
| `entry`       | validates a [entry](http://www.softwareishard.com/blog/har-12-spec/#entry) object                         |
| `log`         | validates a [log](http://www.softwareishard.com/blog/har-12-spec/#log) object                             |
| `page`        | validates a [page](http://www.softwareishard.com/blog/har-12-spec/#page) object                           |
| `pageTimings` | validates a [pageTimings](http://www.softwareishard.com/blog/har-12-spec/#pageTimings) object             |
| `postData`    | validates a [postData](http://www.softwareishard.com/blog/har-12-spec/#postData) object                   |
| `record`      | validates a [record](http://www.softwareishard.com/blog/har-12-spec/#headers) object                      |
| `request`     | validates a [request](http://www.softwareishard.com/blog/har-12-spec/#request) object                     |
| `response`    | validates a [response](http://www.softwareishard.com/blog/har-12-spec/#response) object                   |
| `timings`     | validates a [timings](http://www.softwareishard.com/blog/har-12-spec/#timings) object                     |

###### Example

```js
var HAR = require('har.json');
var validate = require('har-validator');

validate(HAR, function (err, valid) {
  if (err) console.log(err)

  if (valid) {<commit_msg>fix readme<commit_after># HAR Validator [![version][npm-version]][npm-url] [![License][npm-license]][license-url]

Extremely fast HTTP Archive ([HAR](http://www.softwareishard.com/blog/har-12-spec/)) validator using JSON Schema.

[![Build Status][travis-image]][travis-url]
[![Downloads][npm-downloads]][npm-url]
[![Dependencies][david-image]][david-url]

## Installation

install from source or through [npm](https://www.npmjs.com/):

```shell
npm install --global har-validator
```

## Usage

### CLI

```
  Usage: har-validator <file ...>

  Options:

    -h, --help                         output usage information
    -V, --version                      output the version number
    -s, --schema [request | response]  validate sub schema
```

###### Example


```shell
har-validator ./path/to/har.json

har-validator --schema ./path/to/request.json
```

### Code

Include the module in your code and use directly or with any of the utility methods to validate sub-schemas:

| method        | description                                                                                               |
| ------------- | --------------------------------------------------------------------------------------------------------- |
| `cache`       | validates a [cache](http://www.softwareishard.com/blog/har-12-spec/#cache) object                         |
| `cacheEntry`  | validates a ["beforeRequest" or "afterRequest"](http://www.softwareishard.com/blog/har-12-spec/#cache) objects |
| `content`     | validates a [content](http://www.softwareishard.com/blog/har-12-spec/#content) object                     |
| `cookie`      | validates a [cookie](http://www.softwareishard.com/blog/har-12-spec/#cookie) object                       |
| `creator`     | validates a [creator](http://www.softwareishard.com/blog/har-12-spec/#creator) object                     |
| `entry`       | validates a [entry](http://www.softwareishard.com/blog/har-12-spec/#entry) object                         |
| `log`         | validates a [log](http://www.softwareishard.com/blog/har-12-spec/#log) object                             |
| `page`        | validates a [page](http://www.softwareishard.com/blog/har-12-spec/#page) object                           |
| `pageTimings` | validates a [pageTimings](http://www.softwareishard.com/blog/har-12-spec/#pageTimings) object             |
| `postData`    | validates a [postData](http://www.softwareishard.com/blog/har-12-spec/#postData) object                   |
| `record`      | validates a [record](http://www.softwareishard.com/blog/har-12-spec/#headers) object                      |
| `request`     | validates a [request](http://www.softwareishard.com/blog/har-12-spec/#request) object                     |
| `response`    | validates a [response](http://www.softwareishard.com/blog/har-12-spec/#response) object                   |
| `timings`     | validates a [timings](http://www.softwareishard.com/blog/har-12-spec/#timings) object                     |

###### Example

```js
var HAR = require('har.json');
var validate = require('har-validator');

validate(HAR, function (err, valid) {
  if (err) console.log(err)

  if (valid) {
{'fraction_non_alphanumeric': 0.19096347607052896, 'fraction_numerical': 0.009445843828715366, 'mean_word_length': 1.99105461393597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 32, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3033513', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1805, 'n_words': 344}