<commit_before># validately
A simple form validation for NodeJS. 

## Installation

```bash
npm install validately
```

## Getting started

Given a form: 

```html
<form>
  <input type="text" name="sample" />
  <button type="submit">Submit</button>
</form>
```

Posting this form to the server may result in post data which 
looks something like this: 

```js
var formData = {
  'sample': 'This is some sample text!'
};
```

If we want to validate that the "sample" field contains a value, 
we can create a form-validator object with a 'required' validator. 

```js
var validately = require('validately');

var sampleFormValidator = validately({
  'sample': { 'required': true }
});

var validation = sampleValidator.validate(formData);

if (validation.succeeded()) {
  // Happiness :)
} else {
  // Sadness :(
  
  validation.errors('sample').forEach(console.log);
}
```

If the validation fails, the console for this example should print: 

```sh
Sample is required
```

## Default field validators

| Name | Settings | Description |
| :-- | -- | :-- |
| required |  | Ensures that a field contains a value. |
| matches | "target field name" | Ensures that a field's value matches a target field's value. |
| length | { [min: Number], [max: Number] } | Ensures that the length of a field falls within a bound. |

## Custom field validators<commit_msg>Attempt to fix readme.md tables.<commit_after># validately
A simple form validation for NodeJS. 

## Installation

```bash
npm install validately
```

## Getting started

Given a form: 

```html
<form>
  <input type="text" name="sample" />
  <button type="submit">Submit</button>
</form>
```

Posting this form to the server may result in post data which 
looks something like this: 

```js
var formData = {
  'sample': 'This is some sample text!'
};
```

If we want to validate that the "sample" field contains a value, 
we can create a form-validator object with a 'required' validator. 

```js
var validately = require('validately');

var sampleFormValidator = validately({
  'sample': { 'required': true }
});

var validation = sampleValidator.validate(formData);

if (validation.succeeded()) {
  // Happiness :)
} else {
  // Sadness :(
  
  validation.errors('sample').forEach(console.log);
}
```

If the validation fails, the console for this example should print: 

```sh
Sample is required
```

## Default field validators

| Name | Settings | Description |
|:--- |:---:|:--- |
| required | true | Ensures that a field contains a value. |
| matches | "target field name" | Ensures that a field's value matches a target field's value. |
| length | { min: Number, max: Number } | Ensures that the length of a field falls within a bound. |

## Custom field validators
{'fraction_non_alphanumeric': 0.1346294937637564, 'fraction_numerical': 0.0, 'mean_word_length': 3.9762773722627736, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6129971', 'n_tokens_mistral': 854, 'n_tokens_neox': 800, 'n_words': 312}