Improve consistency of text validations
This commit is contained in:
parent
1e57189366
commit
873ac155ca
4 changed files with 7 additions and 9 deletions
|
@ -37,8 +37,8 @@ class DiaryEntry < ActiveRecord::Base
|
||||||
|
|
||||||
scope :visible, -> { where(:visible => true) }
|
scope :visible, -> { where(:visible => true) }
|
||||||
|
|
||||||
validates :title, :body, :presence => true, :invalid_chars => true
|
validates :title, :presence => true, :length => 1..255, :invalid_chars => true
|
||||||
validates :title, :length => 1..255
|
validates :body, :presence => true, :invalid_chars => true
|
||||||
validates :latitude, :allow_nil => true,
|
validates :latitude, :allow_nil => true,
|
||||||
:numericality => { :greater_than_or_equal_to => -90,
|
:numericality => { :greater_than_or_equal_to => -90,
|
||||||
:less_than_or_equal_to => 90 }
|
:less_than_or_equal_to => 90 }
|
||||||
|
|
|
@ -33,8 +33,7 @@ class NoteComment < ActiveRecord::Base
|
||||||
validates :visible, :inclusion => [true, false]
|
validates :visible, :inclusion => [true, false]
|
||||||
validates :author, :associated => true
|
validates :author, :associated => true
|
||||||
validates :event, :inclusion => %w[opened closed reopened commented hidden]
|
validates :event, :inclusion => %w[opened closed reopened commented hidden]
|
||||||
validates :body, :length => { :maximum => 2000 },
|
validates :body, :length => { :maximum => 2000 }, :invalid_chars => true
|
||||||
:invalid_chars => true
|
|
||||||
|
|
||||||
# Return the comment text
|
# Return the comment text
|
||||||
def body
|
def body
|
||||||
|
|
|
@ -31,8 +31,8 @@ class Redaction < ActiveRecord::Base
|
||||||
has_many :old_ways
|
has_many :old_ways
|
||||||
has_many :old_relations
|
has_many :old_relations
|
||||||
|
|
||||||
validates :title, :description, :invalid_chars => true
|
validates :title, :presence => true, :invalid_chars => true
|
||||||
validates :description, :presence => true
|
validates :description, :presence => true, :invalid_chars => true
|
||||||
validates :description_format, :inclusion => { :in => %w[text html markdown] }
|
validates :description_format, :inclusion => { :in => %w[text html markdown] }
|
||||||
|
|
||||||
# this method overrides the AR default to provide the rich
|
# this method overrides the AR default to provide the rich
|
||||||
|
|
|
@ -38,9 +38,8 @@ class Trace < ActiveRecord::Base
|
||||||
scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) }
|
scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) }
|
||||||
|
|
||||||
validates :user, :presence => true, :associated => true
|
validates :user, :presence => true, :associated => true
|
||||||
validates :name, :presence => true, :length => 1..255
|
validates :name, :presence => true, :length => 1..255, :invalid_chars => true
|
||||||
validates :name, :description, :invalid_chars => true
|
validates :description, :presence => { :on => :create }, :length => 1..255, :invalid_chars => true
|
||||||
validates :description, :presence => { :on => :create }, :length => 1..255
|
|
||||||
validates :timestamp, :presence => true
|
validates :timestamp, :presence => true
|
||||||
validates :visibility, :inclusion => %w[private public trackable identifiable]
|
validates :visibility, :inclusion => %w[private public trackable identifiable]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue