25 lines
542 B
JavaScript
Raw Normal View History

'use strict';
2021-10-20 17:30:05 +02:00
const { yup } = require('@strapi/utils');
const { YupValidationError } = require('@strapi/utils').errors;
2021-10-20 17:30:05 +02:00
const handleYupError = error => {
throw new YupValidationError(error);
};
const roleUpdateSchema = yup
.object()
.shape({
name: yup.string().min(1),
description: yup.string().nullable(),
})
.noUnknown();
const validateRoleUpdateInput = data => {
2021-10-20 17:30:05 +02:00
return roleUpdateSchema.validate(data, { strict: true, abortEarly: false }).catch(handleYupError);
};
module.exports = {
validateRoleUpdateInput,
};