0.3.0 • Published 8 years ago

javascript-jsonapi-model-library v0.3.0

Weekly downloads
13
License
-
Repository
github
Last release
8 years ago

javascript-jsonapi-model-library

NPM version Build Status Dependency Status

Provide base model to deal with jsonapi models

Installation

$ npm install --save javascript-jsonapi-model-library

Usage

import Model from 'javascript-jsonapi-model-library';
const schema = 'a json-schema';

class Profile extends Model {
    constructor(values) {
        super(values, schema);

        this.setJsonConfig({
            attributes: ['name', 'email']
        });
    }
}

let profile = new Profile({name: 'Simon', email: 'email@example.com', state: 'approved'});

assert(profile.get('name') === 'Simon');

try {
    profile.validate();

    reply(profile.toJson());
} catch (e) {
    // deal with error
}

License

© Simon Paitrault

0.3.0

8 years ago

0.1.2

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago