class Rpush::Client::ActiveModel::Webpush::Notification::RegistrationValidator

Constants

KEYS

Public Instance Methods

validate(record) click to toggle source
# File lib/rpush/client/active_model/webpush/notification.rb, line 9
def validate(record)
  return if record.registration_ids.blank?
  return if record.registration_ids.size > 1
  reg = record.registration_ids.first
  unless reg.is_a?(Hash) &&
      (KEYS-reg.keys).empty? &&
      reg[:endpoint].is_a?(String) &&
      reg[:keys].is_a?(Hash)
    record.errors.add(:base, 'Registration must have :endpoint (String) and :keys (Hash) keys')
  end
end