Data Modeling in Javascript
heapwolf opened this issue · 1 comments
heapwolf commented
Working on Voltra Co., I’ve needed to validate a lot of data. I’ve tried some pretty clever solutions for validating and describing data. But after working daily with these libraries, I’ve found that the javascript just gets in the way. Too much syntax, too much boiler plate, etc. 50+ models with 30+ entities can become a nightmare to read and maintain.
Anyway, after much GTD I took a break to put together DML. DML is a simple language with the goal of making your data models readable and maintainable. The javascript implementation is only a few hundred lines. The documentation is a work in progress at the moment but the syntax looks like this…
//
// An example data model
//
Date created
Number id
String name
require true "a name is required" // this is a comment
gt 2 "Must be greater than 2 characters"
lte 256 "Must be less than or equal to 256 characters"
String bio
lte 140 "A bio must fit into a tweet"
Boolean accountType
Visit the project on Github.
heapwolf commented
Fucking typo