forked from e621ng/e621ng
[DText] Add newline normalization (#699)
This commit is contained in:
parent
cf94b1b827
commit
9a9f175da4
@ -5,6 +5,7 @@ class Blip < ApplicationRecord
|
||||
simple_versioning
|
||||
belongs_to_creator
|
||||
belongs_to_updater optional: true
|
||||
normalizes :body, with: ->(body) { body.gsub("\r\n", "\n") }
|
||||
validates :body, presence: true
|
||||
validates :body, length: { minimum: 5, maximum: Danbooru.config.blip_max_size }
|
||||
validate :validate_parent_exists, on: :create
|
||||
|
@ -6,6 +6,7 @@ class Comment < ApplicationRecord
|
||||
simple_versioning
|
||||
belongs_to_creator
|
||||
belongs_to_updater
|
||||
normalizes :body, with: ->(body) { body.gsub("\r\n", "\n") }
|
||||
validate :validate_post_exists, on: :create
|
||||
validate :validate_creator_is_not_limited, on: :create
|
||||
validate :post_not_comment_locked, on: :create
|
||||
|
@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Dmail < ApplicationRecord
|
||||
normalizes :body, with: ->(body) { body.gsub("\r\n", "\n") }
|
||||
validates :title, :body, presence: { on: :create }
|
||||
validates :title, length: { minimum: 1, maximum: 250 }
|
||||
validates :body, length: { minimum: 1, maximum: Danbooru.config.dmail_max_size }
|
||||
|
@ -16,6 +16,7 @@ class ForumPost < ApplicationRecord
|
||||
before_validation :initialize_is_hidden, :on => :create
|
||||
after_create :update_topic_updated_at_on_create
|
||||
after_destroy :update_topic_updated_at_on_destroy
|
||||
normalizes :body, with: ->(body) { body.gsub("\r\n", "\n") }
|
||||
validates :body, :creator_id, presence: true
|
||||
validates :body, length: { minimum: 1, maximum: Danbooru.config.forum_post_max_size }
|
||||
validate :validate_topic_is_unlocked
|
||||
|
@ -7,6 +7,7 @@ class Note < ApplicationRecord
|
||||
belongs_to :post
|
||||
belongs_to_creator
|
||||
has_many :versions, -> {order("note_versions.id ASC")}, :class_name => "NoteVersion", :dependent => :destroy
|
||||
normalizes :body, with: ->(body) { body.gsub("\r\n", "\n") }
|
||||
validates :post_id, :creator_id, :x, :y, :width, :height, :body, presence: true
|
||||
validate :user_not_limited
|
||||
validate :post_must_exist
|
||||
|
@ -7,6 +7,7 @@ class Pool < ApplicationRecord
|
||||
array_attribute :post_ids, parse: %r{(?:https://(?:e621|e926)\.net/posts/)?(\d+)}i, cast: :to_i
|
||||
belongs_to_creator
|
||||
|
||||
normalizes :description, with: ->(desc) { desc.gsub("\r\n", "\n") }
|
||||
validates :name, uniqueness: { case_sensitive: false, if: :name_changed? }
|
||||
validates :name, length: { minimum: 1, maximum: 250 }
|
||||
validates :description, length: { maximum: Danbooru.config.pool_descr_max_size }
|
||||
|
@ -18,6 +18,7 @@ class Post < ApplicationRecord
|
||||
before_validation :fix_bg_color
|
||||
before_validation :blank_out_nonexistent_parents
|
||||
before_validation :remove_parent_loops
|
||||
normalizes :description, with: ->(desc) { desc.gsub("\r\n", "\n") }
|
||||
validates :md5, uniqueness: { :on => :create, message: ->(obj, data) {"duplicate: #{Post.find_by_md5(obj.md5).id}"} }
|
||||
validates :rating, inclusion: { in: %w(s q e), message: "rating must be s, q, or e" }
|
||||
validates :bg_color, format: { with: /\A[A-Fa-f0-9]{6}\z/ }, allow_nil: true
|
||||
|
@ -10,6 +10,7 @@ class Ticket < ApplicationRecord
|
||||
before_validation :initialize_fields, on: :create
|
||||
after_initialize :validate_type
|
||||
after_initialize :classify
|
||||
normalizes :reason, with: ->(reason) { reason.gsub("\r\n", "\n") }
|
||||
validates :qtype, presence: true
|
||||
validates :reason, presence: true
|
||||
validates :reason, length: { minimum: 2, maximum: Danbooru.config.ticket_max_size }
|
||||
|
@ -65,6 +65,7 @@ class User < ApplicationRecord
|
||||
validates :email, length: { maximum: 100 }
|
||||
validate :validate_email_address_allowed, on: [:create, :update], if: ->(rec) { (rec.new_record? && rec.email.present?) || (rec.email.present? && rec.email_changed?) }
|
||||
|
||||
normalizes :profile_about, :profile_artinfo, with: ->(value) { value.gsub("\r\n", "\n") }
|
||||
validates :name, user_name: true, on: :create
|
||||
validates :default_image_size, inclusion: { :in => %w(large fit fitv original) }
|
||||
validates :per_page, inclusion: { :in => 1..320 }
|
||||
|
@ -5,6 +5,7 @@ class UserFeedback < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to_creator
|
||||
belongs_to_updater
|
||||
normalizes :body, with: ->(body) { body.gsub("\r\n", "\n") }
|
||||
validates :body, :category, presence: true
|
||||
validates :category, inclusion: { in: %w[positive negative neutral] }
|
||||
validates :body, length: { minimum: 1, maximum: Danbooru.config.user_feedback_max_size }
|
||||
|
@ -7,6 +7,7 @@ class WikiPage < ApplicationRecord
|
||||
before_validation :normalize_other_names
|
||||
before_validation :normalize_parent
|
||||
after_save :create_version
|
||||
normalizes :body, with: ->(body) { body.gsub("\r\n", "\n") }
|
||||
validates :title, uniqueness: { :case_sensitive => false }
|
||||
validates :title, presence: true
|
||||
validates :title, tag_name: true, if: :title_changed?
|
||||
|
Loading…
Reference in New Issue
Block a user