mirror of https://github.com/portainer/portainer
25 lines
754 B
JavaScript
25 lines
754 B
JavaScript
|
angular.module('portainer.services')
|
||
|
.factory('FormValidator', [function FormValidatorFactory() {
|
||
|
'use strict';
|
||
|
|
||
|
var validator = {};
|
||
|
|
||
|
validator.validateAccessControl = function(accessControlData, isAdmin) {
|
||
|
if (!accessControlData.accessControlEnabled) {
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
if (isAdmin && accessControlData.ownership === 'restricted' &&
|
||
|
accessControlData.authorizedUsers.length === 0 &&
|
||
|
accessControlData.authorizedTeams.length === 0) {
|
||
|
return 'You must specify at least one team or user.';
|
||
|
} else if (!isAdmin && accessControlData.ownership === 'restricted' &&
|
||
|
accessControlData.authorizedTeams.length === 0) {
|
||
|
return 'You must specify at least a team.';
|
||
|
}
|
||
|
return '';
|
||
|
};
|
||
|
|
||
|
return validator;
|
||
|
}]);
|