Skip to content

Commit

Permalink
added validation to subject and text
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Hájek committed Oct 7, 2023
1 parent 909a747 commit 2745f77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class ApplicationForm
include ActiveModel::Validations

validate :recipient_present?
validates :subject, presence: true
validates :text, presence: true
validate :subject?
validate :text?

attr_accessor(
# Static/template attributes
Expand Down Expand Up @@ -52,6 +52,14 @@ def valid_template?
def recipient_present?
errors.add(:recipient_name, 'Zvoľte prijímateľa') if recipient_name.blank? || recipient_uri.blank?
end

def subject?
errors.add(:subject, 'Predmet je povinná položka') if subject.blank?
end

def text?
errors.add(:text, 'Text je povinná položka') if text.blank?
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.inputs_set :recipient_body do %>
<%= f.inputs_set :recipient_name do %>
<div id="corporate_bodies_results"></div>
<% end %>
</div>
Expand Down

0 comments on commit 2745f77

Please sign in to comment.