strapi-plugin-i18n
Version:
This plugin enables to create, to read and to update content in different languages, both from the Admin Panel and from the API
31 lines (25 loc) • 824 B
JavaScript
;
const { yup, formatYupErrors } = require('strapi-utils');
const { get } = require('lodash/fp');
const handleReject = error => Promise.reject(formatYupErrors(error));
const validateGetNonLocalizedAttributesSchema = yup
.object()
.shape({
model: yup.string().required(),
id: yup.mixed().when('model', {
is: model => get('kind', strapi.getModel(model)) === 'singleType',
then: yup.strapiID().nullable(),
otherwise: yup.strapiID().required(),
}),
locale: yup.string().required(),
})
.noUnknown()
.required();
const validateGetNonLocalizedAttributesInput = data => {
return validateGetNonLocalizedAttributesSchema
.validate(data, { strict: true, abortEarly: false })
.catch(handleReject);
};
module.exports = {
validateGetNonLocalizedAttributesInput,
};