Skip to content

Commit

Permalink
show length validation message only if there are symbold in field
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriyAndriyovuch committed Sep 16, 2023
1 parent 405d4f9 commit be71728
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/site_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class SiteSetting < ApplicationRecord

has_one_attached :favicon, dependent: :destroy

validates :title, presence: true, length: { minimum: 3, maximum: 30 }
validates :title, presence: true
validates :title, length: { minimum: 3, maximum: 30 }, if: -> { title.present? }
validates :favicon, attached: true,
content_type: [:png, :jpg, :jpeg, :ico],
size: { less_than: 500.kilobytes,
Expand Down

0 comments on commit be71728

Please sign in to comment.