diff options
Diffstat (limited to 'app/models/users/credit_card_validation.rb')
-rw-r--r-- | app/models/users/credit_card_validation.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/users/credit_card_validation.rb b/app/models/users/credit_card_validation.rb index 5e255acd882..a4cc43d1f13 100644 --- a/app/models/users/credit_card_validation.rb +++ b/app/models/users/credit_card_validation.rb @@ -7,5 +7,18 @@ module Users self.table_name = 'user_credit_card_validations' belongs_to :user + + validates :holder_name, length: { maximum: 26 } + 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, + holder_name: holder_name + ).order(credit_card_validated_at: :desc).includes(:user) + end end end |