Class: Rpush::Client::ActiveModel::Apns::NotificationPayloadSizeValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/rpush/client/active_model/apns/notification_payload_size_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



6
7
8
9
10
# File 'lib/rpush/client/active_model/apns/notification_payload_size_validator.rb', line 6

def validate(record)
  limit = record.class.max_payload_bytesize
  return unless record.payload.bytesize > limit
  record.errors.add :base, "APN notification cannot be larger than #{limit} bytes. Try condensing your alert and device attributes."
end