square/lgtm — pull request #5 by jordansexton (2014-07-31 23:03:07+00:00)
Title: Added clone method

I wanted the ability to compose validators to allow client side and server side-specific validation to be separated as necessary and combined in the relevant models, and also allow related models to share validations. A use case might be:

```javascript
// client/validator.js
// Performs basic validations to provide a decent UX
module.exports = require('lgtm').validator().validates('token').required().string();

// server/validator.js
// Performs all the validations the client does, but also validates database column uniqueness, etc.
module.exports = require('../client/validator').clone().validates('token').unique();
```

To this end, I added a `clone` method to the builder and validator classes that does a deep clone for the specific structure of each. I also think it would also be good to have a `merge` method that clones and merges the properties to make composition like this easier.

I wanted to PR this and get input before continuing. The code works in my testing, but I will put together appropriate unit tests if you like this direction.