You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/services/formValidator.js

25 lines
754 B

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;
}]);