mirror of
https://github.com/strapi/strapi.git
synced 2025-07-25 01:49:34 +00:00
21 lines
461 B
JavaScript
21 lines
461 B
JavaScript
'use strict';
|
|
|
|
const { yup, formatYupErrors } = require('@strapi/utils');
|
|
|
|
const hasPermissionsSchema = yup.object({
|
|
actions: yup.array().of(yup.string()),
|
|
hasAtLeastOne: yup.boolean(),
|
|
});
|
|
|
|
const validateHasPermissionsInput = options => {
|
|
try {
|
|
return hasPermissionsSchema.validateSync(options, { strict: true, abortEarly: true });
|
|
} catch (e) {
|
|
throw new Error(formatYupErrors(e));
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
validateHasPermissionsInput,
|
|
};
|