Fix(crud) models w/o associations validation

This commit is contained in:
Joey Baker 2016-10-26 13:26:15 -07:00
parent d3976fa44b
commit 90f72cb07a

View File

@ -63,14 +63,17 @@ export default (server, model, { prefix, defaultConfig: config, models: permissi
const { _singular, _plural, _Singular, _Plural } = target;
return [_singular, _plural, _Singular, _Plural];
}),
];
].filter(Boolean);
const attributeValidation = modelAttributes.reduce((params, attribute) => {
// TODO: use joi-sequelize
params[attribute] = joi.any();
return params;
}, {});
const validAssociations = joi.string().valid(...modelAssociations);
const validAssociations = modelAssociations.length
? joi.string().valid(...modelAssociations)
: joi.valid(null);
const associationValidation = {
include: [joi.array().items(validAssociations), validAssociations],
};