diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /app/models/users | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'app/models/users')
-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 |