<commit_before># Draconian

Draconian is an ultity library for declaratively defining parameter constraints in JavaScript functions. It believes function parameter validation should be extracted from the function itself, and written in a declarative way such that the resulting code is clean and elegant. The parameter validation declaration should also server as documentation that is guaranteed to be up to date.

## Setup

To install:

    npm install draconian

Or add the following line to your package.json's dependencies object:

    "draconian": "*"

To contribute as a developer, you'll need Mocha for run the tests via:

    npm test

## API

Draconiian'ize a function by doing the following:

    var testFunc = Drac.define({
      params: {
        num1: { type: 'number' },
        num2: { type: 'number' optional: true },
        str: { type: 'string' }
      }
    }, function(num1, num2, str) { return num1 + num2 + str; });

And call it:

    testFunc(1, 2, 'hi'); // ouputs 3hi
    testFunc(1, 2, 3); // exception!

### Parameter Options

#### type

JavaScript native type, same as typeof

#### instance

JavaScript parent constructor function, same as instanceof

#### match

JavaScript string regex match

#### notMatch

opposite of match

#### optional

Whether that parameter can be undefined, defaults to false

## Contribute

contact the author <NAME> at <EMAIL><commit_msg>add docs for parameter email check<commit_after># Draconian

Draconian is an ultity library for declaratively defining parameter constraints in JavaScript functions. It believes function parameter validation should be extracted from the function itself, and written in a declarative way such that the resulting code is clean and elegant. The parameter validation declaration should also server as documentation that is guaranteed to be up to date.

## Setup

To install:

    npm install draconian

Or add the following line to your package.json's dependencies object:

    "draconian": "*"

To contribute as a developer, you'll need Mocha for run the tests via:

    npm test

## API

Draconiian'ize a function by doing the following:

    var testFunc = Drac.define({
      params: {
        num1: { type: 'number' },
        num2: { type: 'number' optional: true },
        str: { type: 'string' }
      }
    }, function(num1, num2, str) { return num1 + num2 + str; });

And call it:

    testFunc(1, 2, 'hi'); // ouputs 3hi
    testFunc(1, 2, 3); // exception!

### Parameter Options

#### type

JavaScript native type, same as typeof

#### instance

JavaScript parent constructor function, same as instanceof

#### match

JavaScript string regex match

#### notMatch

opposite of match

#### isEmail

whether the parameter matches

    /^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+$/

#### optional

Whether that parameter can be undefined, defaults to false

## Contribute

contact the author <NAME> at <EMAIL>
{'fraction_non_alphanumeric': 0.08990699276610403, 'fraction_numerical': 0.009645194626248708, 'mean_word_length': 3.5949367088607596, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, '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': '36481', 'n_tokens_mistral': 826, 'n_tokens_neox': 782, 'n_words': 362}