Sha256: d1904174cfacfa59ea9d33098b23f8918ee4b77643ae93151c78d899941c25e0

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

module ShoppingCart
  class CreditCard < ApplicationRecord
    belongs_to :order

    validates :name, :number, :expiration_date, presence: true
    validates :name, length: { maximum: 30 }, format: { with: /\A[A-z\s]+\z/,
                                                        message: "must consist of only letters" }
    validates :number, length: { is: 4 }, format: { with: /\A[0-9]+\z/,
                                                                       message: "must consist of only 4 digits" }
    validates :expiration_date, length: { is: 5 }, format: { with: /\A(0{1}([0-9]){1}|1{1}([0-2]){1})\/\d{2}\z/,
                                                             message: "format must be MM/YY" }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loker-shopping-cart-0.1.3 app/models/shopping_cart/credit_card.rb
loker-shopping-cart-0.1.2 app/models/shopping_cart/credit_card.rb
loker-shopping-cart-0.1.1 app/models/shopping_cart/credit_card.rb