Class: Rpush::Client::ActiveModel::PayloadDataSizeValidator

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

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



5
6
7
8
9
# File 'lib/rpush/client/active_model/payload_data_size_validator.rb', line 5

def validate(record)
  limit = options[:limit] || 1024
  return unless record.data && record.payload_data_size > limit
  record.errors[:base] << "Notification payload data cannot be larger than #{limit} bytes."
end