code: function _addToJSON(error) {
    Object.defineProperty(error, 'toJSON', {
      value: function() {
        return serializeError(this);
      },
      configurable: true,
      writable: true
    });
  }
docs: add a `toJSON` method to an error which allows for errors in validation reports to be serialized properly by `JSON.stringify`.