1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-13 23:48:55 +01:00
fab-manager/app/validators/subscription_group_validator.rb
2023-03-22 10:58:22 +01:00

11 lines
371 B
Ruby

# frozen_string_literal: true
# Check that the current subscription's plan matches the subscribing user's plan
class SubscriptionGroupValidator < ActiveModel::Validator
def validate(record)
return if record.statistic_profile&.group_id == record.plan&.group_id
record.errors.add(:plan_id, "This plan is not compatible with the current user's group")
end
end