1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/app/validators/subscription_group_validator.rb
Sylvain b68e47a0ea refactor shopping_cart/reservation
Previsouly, the reservation was expecting parameters like:
slots_attributes: [{start_at: date, end_at: date, availability_id: number}]

Now, the reservation is expecting simpler parameters like:
slots_reservations_attributes:[{slot_id: number}]
2022-07-18 17:18:01 +02:00

11 lines
369 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[:plan_id] << "This plan is not compatible with the current user's group"
end
end