Sha256: 68627fcb93e1d2c58910cc184a14d6d4dbedd088d7e2bb1037ee831161d9ec50

Contents?: true

Size: 765 Bytes

Versions: 1

Compression:

Stored size: 765 Bytes

Contents

module Shopper
  class AddressForm < Rectify::Form
    attribute :first_name, String
    attribute :last_name,  String
    attribute :street,     String
    attribute :city,       String
    attribute :phone,      String
    attribute :phone,      String
    attribute :zip,        Integer

    attribute :country_id, Integer

    validates :first_name,
              :last_name,
              :street,
              :city,
              :zip,
              :phone,
              :country_id,
              presence: true

    validates :zip, numericality: true
    validates :phone, phone: true

    validate :check_country

    def check_country
      return if Shopper::Country.exists?(country_id)
      errors.add(:country_id, 'don\' exitst')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppper-0.1.0 app/forms/shopper/address_form.rb