https://github.com/kenpusney/infer-schema
https://github.com/kenpusney/infer-schema
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kenpusney/infer-schema
- Owner: kenpusney
- Created: 2019-07-29T15:37:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-01T12:21:51.000Z (over 6 years ago)
- Last Synced: 2025-03-24T01:37:01.511Z (10 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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);
```