Class: Munificent::DonationAmountValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Munificent::DonationAmountValidator
- Defined in:
- app/validators/munificent/donation_amount_validator.rb
Constant Summary collapse
- MINIMUM_DONATION =
Money.new(2_00, "GBP")
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attr_name, value) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/validators/munificent/donation_amount_validator.rb', line 5 def validate_each(record, attr_name, value) unless Currency.supported?(record.public_send("#{attr_name}_currency")) record.errors.add(attr_name, "currency is not supported") end if value < MINIMUM_DONATION record.errors.add(attr_name, "must be at least #{MINIMUM_DONATION.format}") end end |