JavaScript adds Node.js validation library

Tcomb validation library emphasizes models as 'single source of truth' and focuses on early bug detection

Tcomb, a validation library for Node.js and browsers, is being offered as a tool for domain-driven design and runtime checking for JavaScript.

According to GitHub-based documentation, the tcomb library is geared toward the writing of complex domain models "in a breeze and with a small footprint." It also is focused on easy debugging, the enabling of instances that are immutable by default, and encoding and decoding to and from JSON. Types of JavaScript values can be checked at runtime with a simple syntax.

"The main intent of tcomb is to provide a useful tool for domain-driven design that allows [developers] to detect bugs as early as possible," tcomb developer Giulio Canti says. "In my book, models should be the single source of truth, and you should be able to derive as much as you can from them: type safety, validation, documentation, auto generated UIs. These are all satellite projects around tcomb that I'm gonna work on in the next weeks."

Canti, a Web developer and a consultant at e-commerce platform provider Madai Ltd in the United Kingdom, says that the name is derived from a contraction of the words "types" and "combinators." The library defines primitive types and combinators, a function that takes input from some types and returns a new type. When developers create an instance of tcomb, they can rely on its validity; otherwise the debugger kicks in so they can inspect the stack and quickly find out what is wrong, Canti says.

Tcomb features defaults like immutability that can make it easier to work with a system. The road map for tcomb includes exploring the autogeneration of UIs based on the technology. At this stage, the API for tcomb is stable, but Canti is seeking feedback on it from the JavaScript community. The library is being offered under an MIT License.

This story, "JavaScript adds Node.js validation library," was originally published at InfoWorld.com. Get the first word on what the important tech news really means with the InfoWorld Tech Watch blog. For the latest developments in business technology news, follow InfoWorld.com on Twitter.

From CIO: 8 Free Online Courses to Grow Your Tech Skills
Join the discussion
Be the first to comment on this article. Our Commenting Policies