1.0.0 • Published 8 years ago
tcomb-property v1.0.0
tcomb-property
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
1.0.0
8 years ago