<commit_before># Ember Validations #

[![Build Status](https://secure.travis-ci.org/dockyard/ember-validations.svg?branch=master)](http://travis-ci.org/dockyard/ember-validations)

## Building yourself ##

```bash
npm install
bower install
ember build
```

The builds will be in the `dist/` directory.

## Installing ##

#### With Ember-CLI ####

If you are using
[`ember-cli`](https://github.com/stefanpenner/ember-cli) you can add
`ember-validations` to your `package.json`:

```javascript
"devDependencies": {
  ...
  "ember-validations": "~ 2.0.0"
}
```

You may want to be more precise with your version locking.

#### Without Ember-CLI ####

We will continue to build `EmberValidations` to the DockYard build
server until `ember-cli` is officially recommended by Ember. You can
select a build version from:
[http://builds.dockyard.com](http://builds.dockyard.com) for use in
Bower.

## Looking for help? ##

If it is a bug [please open an issue on GitHub](https://github.com/dockyard/ember-validations/issues).

## Usage ##

You need to mixin `EmberValidations` into any `Ember.Object` you want to add
validations to:

```javascript
import Ember from 'ember';
import EmberValidations from 'ember-validations';

export default Ember.Controller.extend(EmberValidations);
```

You define your validations as a JSON object. They should be added to
the controller that represents the model in question.
The keys in the object should map to properties. If you pass a
JSON object as the value this will be seen as validation rules to apply
to the property. If you pass `true` then the property itself will be
seen as a validatable object.

```javascript
import Ember from 'ember';
import EmberValidations from 'ember-validations';

export default Ember.Controller.extend(EmberValidations, {
  validations: {
    'model.firstName': {
      presence: true,
      length: { minimum: 5 }
    },
    'model.age': {
      numericality: true
    },
    'model.profile': true
  }
});
```

Though not yet explicitly part of the API, you can also add validators
to nested objects:

```javascript
import Ember from 'ember';
import EmberValidations from 'ember-validations';

export default Ember.Component.extend(EmberValidations, {
  validations: {
    'user.firstName': {
      presence: true,
      length: { minimum: 5 }
    }
  }
});
```

This is useful for things like Components which don't act as proxies, but
again, until this is officially built into the project, YMMV.

**Note: If you override the init function, you must call _super()**

```javascript<commit_msg>add link to YMMV explanation<commit_after># Ember Validations #

[![Build Status](https://secure.travis-ci.org/dockyard/ember-validations.svg?branch=master)](http://travis-ci.org/dockyard/ember-validations)

## Building yourself ##

```bash
npm install
bower install
ember build
```

The builds will be in the `dist/` directory.

## Installing ##

#### With Ember-CLI ####

If you are using
[`ember-cli`](https://github.com/stefanpenner/ember-cli) you can add
`ember-validations` to your `package.json`:

```javascript
"devDependencies": {
  ...
  "ember-validations": "~ 2.0.0"
}
```

You may want to be more precise with your version locking.

#### Without Ember-CLI ####

We will continue to build `EmberValidations` to the DockYard build
server until `ember-cli` is officially recommended by Ember. You can
select a build version from:
[http://builds.dockyard.com](http://builds.dockyard.com) for use in
Bower.

## Looking for help? ##

If it is a bug [please open an issue on GitHub](https://github.com/dockyard/ember-validations/issues).

## Usage ##

You need to mixin `EmberValidations` into any `Ember.Object` you want to add
validations to:

```javascript
import Ember from 'ember';
import EmberValidations from 'ember-validations';

export default Ember.Controller.extend(EmberValidations);
```

You define your validations as a JSON object. They should be added to
the controller that represents the model in question.
The keys in the object should map to properties. If you pass a
JSON object as the value this will be seen as validation rules to apply
to the property. If you pass `true` then the property itself will be
seen as a validatable object.

```javascript
import Ember from 'ember';
import EmberValidations from 'ember-validations';

export default Ember.Controller.extend(EmberValidations, {
  validations: {
    'model.firstName': {
      presence: true,
      length: { minimum: 5 }
    },
    'model.age': {
      numericality: true
    },
    'model.profile': true
  }
});
```

Though not yet explicitly part of the API, you can also add validators
to nested objects:

```javascript
import Ember from 'ember';
import EmberValidations from 'ember-validations';

export default Ember.Component.extend(EmberValidations, {
  validations: {
    'user.firstName': {
      presence: true,
      length: { minimum: 5 }
    }
  }
});
```

This is useful for things like Components which don't act as proxies, but
again, until this is officially built into the project, [YMMV](http://www.urbandictionary.com/define.php?term=ymmv).

**Note: If you override the init function, you must call _super()**

```javascript
{'fraction_non_alphanumeric': 0.11528098537336412, 'fraction_numerical': 0.001924557351809084, 'mean_word_length': 4.1918081918081915, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 1, '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': '4239712', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1556, 'n_words': 573}