<commit_before># Avery

[![NPM](https://nodei.co/npm/avery.png)](https://npmjs.org/package/avery)

Immutable models with virtuals and `Joi`-ful validation.

### API

See usage below (it's pretty simple), and then go look at
[ImmutableJS](http://facebook.github.io/immutable-js/).

Methods we add:

- `isValid` - returns true if the model passed validation. You shouldn't need
anything else.

### Usage

```javascript

var Avery = require('avery');

var User = Avery.Model({
  name : 'User',

  defaults : {
    id : null,
    email : null,
    password : <PASSWORD>,
    firstName : null,
    lastName : null
  },

  validate : Joi.object().keys({
    id : Joi.number(),
    email : Joi.string().email(),
    password : <PASSWORD>(),
    firstName : Joi.string(),
    lastName : Joi.string()
  }),

  virtuals : {
    fullName : function() {
      // this is bound to the ImmutableJS record
      return this.get('firstName') + ' ' + this.get('lastName');
    }
  }

});

var myUser = new User({
  id : 1,
  email : '<EMAIL>',
  password : '<PASSWORD>',
  firstName : 'Sterling',
  lastName : 'Archer'
});

myUser.get('fullName'); // === "<NAME>"
myUser.get('email'); // === "<EMAIL>"

myUser.set('id', 2);
myUser.get('id'); // === 1

var mutatedUser = myUser.set('id', 2);
myUser === mutatedUser; // === false
mutatedUser.get('id'); // === 2

```
<commit_msg>update suggested usage<commit_after># Avery

[![NPM](https://nodei.co/npm/avery.png)](https://npmjs.org/package/avery)

Immutable models with virtuals and `Joi`-ful validation.

### API

See usage below (it's pretty simple), and then go look at
[ImmutableJS](http://facebook.github.io/immutable-js/).

Methods we add:

- `isValid` - returns true if the model passed validation. You shouldn't need
anything else.

### Usage

```javascript

var Avery = require('avery');

class User extends Avery.Model({
  defaults : {
    id : null,
    email : null,
    password : <PASSWORD>,
    firstName : null,
    lastName : null
  },

  validate : Joi.object().keys({
    id : Joi.number(),
    email : Joi.string().email(),
    password : Joi.string(),
    firstName : Joi.string(),
    lastName : Joi.string()
  }),

  virtuals : {
    fullName : function() {
      // this is bound to the ImmutableJS record
      return this.get('firstName') + ' ' + this.get('lastName');
    }
  }
}) {

  myMethod() {
    return this.get('fullName');
  }

};

var myUser = new User({
  id : 1,
  email : '<EMAIL>',
  password : '<PASSWORD>',
  firstName : 'Sterling',
  lastName : 'Archer'
});

myUser.get('fullName'); // === "<NAME>"
myUser.get('email'); // === "<EMAIL>"

myUser.set('id', 2);
myUser.get('id'); // === 1

var mutatedUser = myUser.set('id', 2);
myUser === mutatedUser; // === false
mutatedUser.get('id'); // === 2

```

{'fraction_non_alphanumeric': 0.1930835734870317, 'fraction_numerical': 0.0036023054755043226, 'mean_word_length': 3.163418290854573, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 4, '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': '2512196', 'n_tokens_mistral': 996, 'n_tokens_neox': 957, 'n_words': 236}