summaryrefslogtreecommitdiff
path: root/app/models/product.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/product.rb')
-rw-r--r--app/models/product.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/product.rb b/app/models/product.rb
index d12cd41..72d7f33 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -11,6 +11,14 @@
class Product < ApplicationRecord
belongs_to :company
+ validates :name, presence: true
+ validates :unitary_price, presence: true
+ validates :unitary_price, comparison: { greater_than: 0 }
+ validates :bulk_price, presence: true
+ validates :bulk_price, comparison: { greater_than: 0 }
+ validates :available_quantity, presence: true
+ validates :available_quantity, comparison: { greater_than: 0 }
+
has_one_attached :picture
serialize :categories, Array