summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-27 20:04:00 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-27 20:04:00 -0600
commit35ec25dcb3d57b17a3dc174503b7d20dd4c46e43 (patch)
tree4bf53848d7460947b9c70aa74dc934279d94af55 /app
parent7b5d00f1bf262cc40b6b9dc21bb42e2dc7c80afe (diff)
Añade specs de Card
Diffstat (limited to 'app')
-rw-r--r--app/models/card.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/models/card.rb b/app/models/card.rb
index ae2b1e5..594ae43 100644
--- a/app/models/card.rb
+++ b/app/models/card.rb
@@ -1,3 +1,20 @@
+# frozen_string_literal: true
+
+# Card
+# number: string
+# expiration_month: integer
+# expiration_year: integer
+# expiration_day: integer
+# security_code: integer
class Card < ApplicationRecord
belongs_to :user_account
+ validates :number, presence: true, uniqueness: true, length: { is: 16 }
+ validates :expiration_year, presence: true, numericality: { greater_than: 1970 }
+ validates :expiration_month, presence: true, inclusion: { in: 1..12 }
+ validates :expiration_day, presence: true, inclusion: { in: 1..31 }
+ validates :security_code, presence: true
+
+ def expiration_date
+ "#{expiration_day}/#{expiration_month}/#{expiration_year}"
+ end
end