tcomb-property

1.0.0 • Public • Published

tcomb-property

Build Status

Alternative syntax for defining default props in tcomb structures

Install

$ npm install --save tcomb-property

Usage

import t from 'tcomb';
import { property, createInstance } from 'tcomb-property';

const Show = t.struct({
  title: t.String,
  duration: property(t.String, '40m'),
  network: t.struct({
    country: property(t.String, 'USA')
  })
});

createInstance(Show)
/*
{
  title: undefined,
  duration: '40m',
  network: {
    country: 'USA'
  }
}
*/

createInstance(Show, { title: 'Top Gear', duration: '20m', network: { country: 'UK' } })
/*
{
  title: 'Top Gear',
  duration: '20m',
  network: {
    country: 'UK'
  }
}
*/

Related

License

MIT © ewnd9

Readme

Keywords

Package Sidebar

Install

npm i tcomb-property

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • ewnd9