Skip to content
No description, website, or topics provided.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.babelrc
.editorconfig
.eslintignore
.eslintrc
.gitignore
.travis.yml
README.md
index.js
package.json
webpack.config.dev.js
webpack.config.prod.js
yarn.lock

README.md

Warning:

DO NOT USE THIS IN PRODUCTION, NOT FULLY TEST YET

Install

npm install schemaor

or

yarn add schemaor

Usage

  • Basic: Define schema without constraint:
import {Schema} from 'schemaor'
const Person = Schema({
  name: '',
  age: ''
})

// Instantiate:
const person = Person({
  name: 'Lee',
  age: 22
})
  • Field data type constraint:
import {Schema, Types} from 'schemaor'
const Person = Schema({
  name: Types().string(),
  age: Types().number()
})
  • Other kind of constraint: default(), required(), valueof()
import {Schema, Types} from 'schemaor'
const Person = Schema({
  name: Types().string().default('').required(),
  age: Types().number().default(22).required(),
  title: Types().valueof('coder', 'programmer')
})
  • Nested schema
import {Schema, Types} from 'schemaor'
const Person = Schema({
  job: Schema({
    title: '',
    company: ''
  })
})
You can’t perform that action at this time.