mirror of
https://github.com/strapi/strapi.git
synced 2025-07-21 16:10:18 +00:00
23 lines
501 B
JavaScript
23 lines
501 B
JavaScript
'use strict';
|
|
|
|
const { yup, formatYupErrors } = require('strapi-utils');
|
|
|
|
const settingsSchema = yup.object({
|
|
sizeOptimization: yup.boolean().required(),
|
|
responsiveDimensions: yup.boolean().required(),
|
|
});
|
|
|
|
const validateSettings = data => {
|
|
return settingsSchema
|
|
.validate(data, {
|
|
abortEarly: false,
|
|
})
|
|
.catch(error => {
|
|
throw strapi.errors.badRequest('ValidationError', {
|
|
errors: formatYupErrors(error),
|
|
});
|
|
});
|
|
};
|
|
|
|
module.exports = validateSettings;
|