Sha256: 8cc4f070ada7215ba3e975061eedd1cc5907cf5f5c09a3310b75000b11b3ae79
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Account class BillingForm < ApplicationForm attribute :account_type_id, Integer attribute :country_code, String attribute :city, String attribute :vat_code, String attribute :address_1, String attribute :address_2, String attribute :zip_code, String validates :account_type_id, presence: true, length: { maximum: 1 }, inclusion: { in: AccountType.all.map(&:id) } validates :city, length: { maximum: 100 }, allow_blank: true validates :vat_code, length: { maximum: 30 }, allow_blank: true validates :address_1, length: { maximum: 200 }, allow_blank: true validates :address_2, length: { maximum: 200 }, allow_blank: true validates :zip_code, length: { maximum: 10 }, allow_blank: true validates :country_code, length: { maximum: 3 }, allow_blank: true validate :valid_country_code? def submit return false unless valid? api_answer = TranslationCms::Api::Customers::BillingAddress.create(billing_address: attributes) merge_responce! api_answer errors.empty? end protected def valid_country_code? return if country_code.blank? errors.add(:country_code, :invalid) if ISO3166::Country.find_country_by_alpha3(country_code).nil? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translation_cms-0.1.5 | app/forms/account/billing_form.rb |