Mailspring/api/serialization.js

26 lines
442 B
JavaScript
Raw Normal View History

2016-06-19 18:02:32 +08:00
const Joi = require('joi');
function replacer(key, value) {
// force remove any disallowed keys here
return value;
}
function jsonSchema(modelName) {
if (modelName === 'Account') {
return Joi.object().keys({
id: Joi.number(),
email_address: Joi.string(),
})
}
return null;
}
function jsonStringify(models) {
return JSON.stringify(models, replacer, 2);
}
module.exports = {
jsonSchema,
jsonStringify,
}