<commit_before># validate-params
**A small parameter validation library**

[![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url]

# License
MIT - [view the full license here] (LICENSE)

[travis-url]: https://travis-ci.org/mdvorscak/validate-params
[travis-image]: https://travis-ci.org/mdvorscak/validate-params.svg?branch=master

[coveralls-url]: https://coveralls.io/r/mdvorscak/validate-params?branch=master
[coveralls-image]: https://coveralls.io/repos/mdvorscak/validate-params/badge.svg?branch=master<commit_msg>Added basic documentation/examples in readme<commit_after># validate-params
**A small parameter validation library**

The purpose of this library is to easily check that the contract of your functions is not violated; and if it is, to allow
you to gracefully handle the situation (provide useful error messages).

[![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url]

# Basic examples
```js
var Validator = require('validate-params');

// validating a single argument
function simpleWrapper(callback){
    Validator.assert.arg(callback, 'function');
    //Then do something with the callback later, at this point we can be sure that callback is a function
}

simpleWrapper(42); //throws Error('Expected type "function" but it was type "number"')

// validating an argument object
function myCoolFunction(opts){
    Validator.assert.arg(opts,
    {name: 'string',
    //handles optional parameters
     phoneNum: {
        type: 'string',
        optional: true
     },
     //handles nested objects
     location: {
        city: 'string',
        longitude: 'number',
        latitude: 'number'
     }
    });
    //...
}

myCoolFunction({name: 'Jenny',
                phoneNum: '876-5309',
                location: {
                   city: 'Chicago',
                   longitude: 87.6847,
                   latitude: 41.8369
                }
               });

```

# Documentation
To learn more checkout the [documentation page] (docs/index.md)

# License
MIT - [view the full license here] (LICENSE)

[travis-url]: https://travis-ci.org/mdvorscak/validate-params
[travis-image]: https://travis-ci.org/mdvorscak/validate-params.svg?branch=master

[coveralls-url]: https://coveralls.io/r/mdvorscak/validate-params?branch=master
[coveralls-image]: https://coveralls.io/repos/mdvorscak/validate-params/badge.svg?branch=master
{'fraction_non_alphanumeric': 0.13155737704918033, 'fraction_numerical': 0.00860655737704918, 'mean_word_length': 3.503690036900369, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, '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': '1389275', 'n_tokens_mistral': 762, 'n_tokens_neox': 737, 'n_words': 181}