Sha256: 873760495dcd2d0c9213440fcdaa9f055550cdccca25de3f31ae3572eee9ad3f
Contents?: true
Size: 1.07 KB
Versions: 17
Compression:
Stored size: 1.07 KB
Contents
module Medivo class PrimaryInsurance include ActiveModel::Validations include ActiveModel::Serializers::Xml validates_presence_of :relationship, :company_name, :policy_number validates :relationship, :inclusion => {:in => 1..2} def initialize(attributes = {}) @attributes = attributes end def read_attribute_for_validation(key) @attributes[key] end def attributes @attributes.stringify_keys end # for use by InsuranceOrder to validate its primary insurance def validate(record) primary_insurance = record.attributes['primary_insurance'] record.errors.add(:primary_insurance, "primary_insurance field must be present") and return unless primary_insurance record.errors.add(:primary_insurance, "primary_insurance field must be of PrimaryInsurance class") and return unless primary_insurance.is_a? PrimaryInsurance primary_insurance.valid? primary_insurance.errors.messages.each do |field, value| record.errors.add(:"primary_insurance.#{field}", value.first) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems