packages/lobsang-formatter-schema/lib/lobsang-formatter-schema.js
function lobsangFormatterSchema (message, topic) {
  if (typeof message !== 'string') {
    return Promise.reject(new Error('Message is not a string'))
  }

  return schema(topic)
    .then((schemaObject) => {
      const validator = validate(schemaObject)
      const schemaMessage = format(message)

      if (validator(schemaMessage)) {
        return Promise.resolve(schemaMessage)
      }
      return Promise.reject(validator.errors)
    })
}
function lobsangFormatterSchema (message, topic) {
  if (typeof message !== 'string') {
    return Promise.reject(new Error('Message is not a string'))
  }

  return schema(topic)
    .then((schemaObject) => {
      const validator = validate(schemaObject)
      const schemaMessage = format(message)

      if (validator(schemaMessage)) {
        return Promise.resolve(schemaMessage)
      }
      return Promise.reject(validator.errors)
    })
}
@module @lobsangnet/lobsang-formatter-matrix
 
Library to wrap a message into an object which complies to the given schema.

@public
@param {string} message - The message to format.
@param {string} topic - The topic in which the message should be published.
@returns {Promise<any|Error>}
Promise which resolves to a SchemaMessage.
Or an Error if something went wrong.
@todo Replace any after https://github.com/Kegsay/flow-jsdoc/issues/22