Class: Paypal::Masspay::LengthValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/paypal/masspay/length_validator.rb

Defined Under Namespace

Classes: FieldLengthTooLarge

Class Method Summary collapse

Class Method Details

.validate(string, length, field_name) ⇒ Object



5
6
7
8
9
# File 'lib/paypal/masspay/length_validator.rb', line 5

def self.validate(string, length, field_name)
  string.tap do |output|
    raise FieldLengthTooLarge.new("#{output} is longer than the paypal max char limit of #{length} for field #{field_name}") if !output.nil? && output.length > length
  end
end