1.2.0 • Published 8 years ago

pi-model v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

NPM version Build Status Coverage Status Dependency Status

PiModel

PiModel is a simple data model representation that allows data validation and some basic features.

It is aimed to be used in a more organized data accesses (repository, datamapper, datasource, etc.).

Install

npm install pi-model

Usage

// New model definition 
var ModelBuilder = require('pi-model'),
    User         = new ModelBuilder({
      'name' : 'UserModel'
    });

// Model usage
var myUser = new User({
  'firstName' : 'John',
  'lastName'  : 'Doe'
});

Builder options

The model builder accepts the following options :

{
  'name' : String,
  'description' : Object,
  'validator' : Function
}
  • name : String used to define the model
  • description : Object describing custom information of the model
  • validator : Instance used to validate data over the schema

Validator

You can use pi-validator-tv4 if needed. It is a simple encapsulation of tv4 (validation with JSON schema).

Create a custom validator

If you need to create your own validator, you can base extend pi-validator.

It is an abstraction of the validator.

1.2.0

8 years ago

1.1.0

8 years ago

1.0.5

8 years ago

1.0.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago