Sha256: f6c0ad9c59d63c1a9d3b241ea7b671501c95a00c30e139e4b06f57f13ea90760
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
medivo-0.2.24 | app/models/medivo/primary_insurance.rb |