mirror of
https://github.com/strapi/strapi.git
synced 2025-08-08 00:37:38 +00:00
23 lines
475 B
JavaScript
23 lines
475 B
JavaScript
'use strict';
|
|
|
|
const { yup, formatYupErrors } = require('strapi-utils');
|
|
|
|
const hasPermissionsSchema = yup.array().of(
|
|
yup.object().shape({
|
|
action: yup.string().required(),
|
|
subject: yup.string(),
|
|
})
|
|
);
|
|
|
|
const validateHasPermissionsInput = data => {
|
|
try {
|
|
return hasPermissionsSchema.validateSync(data, { strict: true, abortEarly: true });
|
|
} catch (e) {
|
|
throw new Error(formatYupErrors(e));
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
validateHasPermissionsInput,
|
|
};
|