An open API service indexing awesome lists of open source software.

https://github.com/kenpusney/infer-schema


https://github.com/kenpusney/infer-schema

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

# Schema

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

### Example
```js
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
```js
Party.validate(party);
```