infer-schema

1.1.2 • Public • Published

Schema

See http://kimleo.net/infer for type system details.

Example

const Phone = new Schema({
    areaCode: String,
    number: String,
    extension: String,
});

const Name  = new Schema({
    firstName: String,
    middleName: String,
    lastName: String,
});

const Contact = new Schema({
    emails: [ { tag: String, email: String } ],
    phones: [ { tag: String, phone: new Union(String, Phone) } ],
})

const Party = new Schema({
    // _id: String,
    nickname: String,
    names: {
        legal: Name,
        prefered: Name,
        foreign: [ { tag: String, name: Name } ],
    },
    contact: Contact,

    tags: [String],

    extensions: Object,
});

To validate an object, just simply run

Party.validate(party);

Readme

Keywords

none

Package Sidebar

Install

npm i infer-schema

Weekly Downloads

3

Version

1.1.2

License

MIT

Unpacked Size

9.95 kB

Total Files

4

Last publish

Collaborators

  • kenpusney