Class: Legion::Data::Model::RBAC::RoleAssignment

Inherits:
Object
  • Object
show all
Includes:
ModelHelpers
Defined in:
lib/legion/data/models/rbac/role_assignments.rb

Constant Summary collapse

VALID_PRINCIPAL_TYPES =
%w[worker human].freeze

Instance Method Summary collapse

Methods included from ModelHelpers

#actions_list, #active?, #expired?

Instance Method Details

#validateObject



14
15
16
17
18
19
20
# File 'lib/legion/data/models/rbac/role_assignments.rb', line 14

def validate
  super
  errors.add(:principal_type, 'must be worker or human') unless VALID_PRINCIPAL_TYPES.include?(principal_type)
  errors.add(:principal_id, 'cannot be empty') if principal_id.nil? || principal_id.empty?
  errors.add(:role, 'cannot be empty') if role.nil? || role.empty?
  errors.add(:granted_by, 'cannot be empty') if granted_by.nil? || granted_by.empty?
end