<commit_before># schema.js

* implements data schema validation and adaptation according to [JSON Schema](http://json-schema.org/) ([draft 2](http://tools.ietf.org/html/draft-zyp-json-schema-02)) for JavaScript (CommonJS).
* serves as both validator and documentation of your project's data models
* is sophisticated: environments, recursion detection, tolerant value adaptation, extendable
* makes your development more agile. You don't need to unit test your validators any more.

## API

### Environment

The environment is a context, where your schemas and validations live in. You need to create an environment before creating your schemas to define some default settings that will affect all schemas created in this environment:

```js
var myEnv = require('schema')('envIdentifier', options)
```

* The identifier is optional but recommended to retrieve the same environment - without options - in another script.
* `options` is an object that can have the following keys:
  * `'i18n'` is a list of module identifiers or i18n packages that will be used inside this environment. To omit all messages in the validation errors, just use `[]`. [Example for an i18n module](http://github.com/akidee/schema.js/blob/master/i18n/default.js)
Default: `[ '../i18n/default' ]`
  * `'fallbacks'` defines the default fallbacks that are used when a schema is defined without the `"fallbacks"` attribute. Options: `'TOLERANT_FALLBACKS'`, `'STRICT_FALLBACKS'` or any other legal definition of the `"fallbacks"` attribute. Default: `'TOLERANT_FALLBACKS'`<commit_msg>Install hint<commit_after># schema.js

* implements data schema validation and adaptation according to [JSON Schema](http://json-schema.org/) ([draft 2](http://tools.ietf.org/html/draft-zyp-json-schema-02)) for JavaScript (CommonJS).
* serves as both validator and documentation of your project's data models
* is sophisticated: environments, recursion detection, tolerant value adaptation, extendable
* makes your development more agile. You don't need to unit test your validators any more.

## Installation

```sh
npm install schema
```

## API

### Environment

The environment is a context, where your schemas and validations live in. You need to create an environment before creating your schemas to define some default settings that will affect all schemas created in this environment:

```js
var myEnv = require('schema')('envIdentifier', options)
```

* The identifier is optional but recommended to retrieve the same environment - without options - in another script.
* `options` is an object that can have the following keys:
  * `'i18n'` is a list of module identifiers or i18n packages that will be used inside this environment. To omit all messages in the validation errors, just use `[]`. [Example for an i18n module](http://github.com/akidee/schema.js/blob/master/i18n/default.js)
Default: `[ '../i18n/default' ]`
  * `'fallbacks'` defines the default fallbacks that are used when a schema is defined without the `"fallbacks"` attribute. Options: `'TOLERANT_FALLBACKS'`, `'STRICT_FALLBACKS'` or any other legal definition of the `"fallbacks"` attribute. Default: `'TOLERANT_FALLBACKS'`
{'fraction_non_alphanumeric': 0.09632446134347275, 'fraction_numerical': 0.008238276299112801, 'mean_word_length': 5.082851637764932, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1947823', 'n_tokens_mistral': 870, 'n_tokens_neox': 834, 'n_words': 377}