debian-mirror-gitlab/app/models/users/credit_card_validation.rb

26 lines
671 B
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
module Users
class CreditCardValidation < ApplicationRecord
RELEASE_DAY = Date.new(2021, 5, 17)
self.table_name = 'user_credit_card_validations'
belongs_to :user
2021-11-18 22:05:49 +05:30
2022-05-07 20:08:51 +05:30
validates :holder_name, length: { maximum: 50 }
2021-12-11 22:18:48 +05:30
validates :network, length: { maximum: 32 }
2021-11-18 22:05:49 +05:30
validates :last_digits, allow_nil: true, numericality: {
greater_than_or_equal_to: 0, less_than_or_equal_to: 9999
}
def similar_records
self.class.where(
expiration_date: expiration_date,
last_digits: last_digits,
2021-12-11 22:18:48 +05:30
network: network
2021-11-18 22:05:49 +05:30
).order(credit_card_validated_at: :desc).includes(:user)
end
2021-06-08 01:23:25 +05:30
end
end