mirror of
https://github.com/strapi/strapi.git
synced 2025-07-27 19:10:01 +00:00
25 lines
542 B
JavaScript
25 lines
542 B
JavaScript
'use strict';
|
|
|
|
const { yup } = require('@strapi/utils');
|
|
const { YupValidationError } = require('@strapi/utils').errors;
|
|
|
|
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 => {
|
|
return roleUpdateSchema.validate(data, { strict: true, abortEarly: false }).catch(handleYupError);
|
|
};
|
|
|
|
module.exports = {
|
|
validateRoleUpdateInput,
|
|
};
|