Skip to content

Commit

Permalink
Prevent (-)ve value selection for standard price
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank0109 committed Feb 18, 2022
1 parent 1597e29 commit a08c20b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ class Company < ApplicationRecord
has_one_attached :logo

validates :name, :business_phone, :standard_price, :country, :base_currency, presence: true
validates :standard_price, numericality: { greater_than_or_equal_to: 0 }
end
2 changes: 1 addition & 1 deletion app/views/companies/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</div>
</div>
<div class="mt-1">
<%= form.number_field :standard_price, autofocus: true, class: "rounded tracking-wider border block w-full px-3 py-2 bg-miru-gray-100 shadow-sm text-xs text-miru-dark-purple-1000 focus:outline-none #{error_message_class(form.object, :standard_price)}" %>
<%= form.number_field :standard_price, min: 0, autofocus: true, class: "rounded tracking-wider border block w-full px-3 py-2 bg-miru-gray-100 shadow-sm text-xs text-miru-dark-purple-1000 focus:outline-none #{error_message_class(form.object, :standard_price)}" %>
</div>
</div>
</div>
Expand Down

0 comments on commit a08c20b

Please sign in to comment.