gcanti / tcomb

Type checking and DDD for JavaScript
MIT License
1.89k stars 120 forks source link

Default value #309

Open piranna opened 6 years ago

piranna commented 6 years ago

So far I've seen it's only possible to define default values on the structs, but there's no possibility in other types. One option would be to add an optional default value to the maybe function, so if a value is not defined or is null, the default is returned.

ArmorDarks commented 6 years ago

Sounds reasanoble.

It also will help to avoid duplicating structure in structure itself and than it's "defaults" declaration.

piranna commented 6 years ago

I'm glad you liked my suggestion :-)