diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index af85615..62a8b84 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -303,4 +303,9 @@ form textarea { .cd{ margin-top: 10px; +} + +.error{ + font-size: 18px; + color: red; } \ No newline at end of file diff --git a/app/models/group.rb b/app/models/group.rb index 4c7d730..b4bb4cc 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,4 +1,7 @@ class Group < ApplicationRecord belongs_to :user has_many :transactions + + validates :name, presence: true, length: { maximum: 20 } + validates :icon, presence: true end \ No newline at end of file diff --git a/app/models/transaction.rb b/app/models/transaction.rb index c835495..06c58b1 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -2,4 +2,11 @@ class Transaction < ApplicationRecord belongs_to :user belongs_to :group, optional: true + validates :name, presence: true, length: { maximum: 20 } + validates :amount, presence: true, numericality: { less_than_or_equal_to: 100_000, greater_than: 1 } + + + + + end \ No newline at end of file diff --git a/app/views/groups/_form.html.erb b/app/views/groups/_form.html.erb index b1119c5..8240a20 100644 --- a/app/views/groups/_form.html.erb +++ b/app/views/groups/_form.html.erb @@ -1,4 +1,12 @@ <%= form_for @group do |f| %> + + <% if @group.errors.any? %> + + <% end %> <%= f.label :name %>
<%= f.text_field :name %>
diff --git a/app/views/transactions/_form.html.erb b/app/views/transactions/_form.html.erb index be45367..8f52a4f 100644 --- a/app/views/transactions/_form.html.erb +++ b/app/views/transactions/_form.html.erb @@ -1,4 +1,14 @@ <%= form_for @transaction do |f| %> + + <% if @transaction.errors.any? %> + + <% end %> + + <%= f.label :name %>
<%= f.text_field :name %>