mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-30 17:37:26 +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,
 | |
| };
 | 
