When it first came out, I was a really big fan of flatiron. I made some contributions to some of the packages in flatiron. That was fun and nice. However, the more I used it, the less I agreed with its opinions. No big deal, right? Either suck it up and drive on or move onto another library or write your own.
That’s the way of open-source software. I like that ecosystem.
I still really like two of the flatiron libraries:
- A high-level, caching, CouchDB client for Node.js
- A cross-browser / node.js validator used by resourceful and flatiron. Revalidator has JSONSchema compatibility as primary goal.
I don’t use cradle because I wrote stork. No problem.
revalidator creates a library that mimics the JSON Schema specification to validate objects rather than JSON-formatted documents. That’s even nicer.
Let’s say I want to have an object that has a required
firstName property, a
lastName property that must have a length longer than 3 characters
(sorry, Jennifer Wu!),
and an optional numeric
age property, then I can use revalidator to
express those expectations with the following code.
var revalidator, schema;
The return value of the
validate call returns an object like this:
That’s awesome. It solves all my problems!
I’ve used revalidator in a couple of projects, now. But, with my work on stork, I need something beyond the possibilities of revalidator. So, I have one of two options, here.
- Write my own validation library; or,
- Fork revalidator, make it extensible, and give back.
I think the second option wins hands down. The authors of revalidator have done a really good job at writing clear and concise code. Thank you, flatiron guys!
I guess that’s what I’m going to do.
And, now I’ve done it. If you want to help out with the refactoring of revalidator to support more validations, do the GitHub thing: fork, write, test, pull request.