class Rpush::Client::ActiveModel::Fcm::NotificationKeysInAllowedListValidator

Public Instance Methods

validate(record) click to toggle source
# File lib/rpush/client/active_model/fcm/notification_keys_in_allowed_list_validator.rb, line 6
def validate(record)
  return unless record.notification

  allowed_keys = Notification::ROOT_NOTIFICATION_KEYS + Notification::ANDROID_NOTIFICATION_KEYS
  invalid_keys = record.notification.keys - allowed_keys

  return if invalid_keys.empty?

  record.errors.add(:notification, "contains invalid keys: #{invalid_keys.join(', ')}")
end