1
0
Fork 0

Use GoodSmallTextValidator

This commit is contained in:
Alex Kotov 2019-09-30 16:51:05 +05:00
parent 25dea68be5
commit 779bc0a704
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 6 additions and 35 deletions

View file

@ -1,8 +1,6 @@
# frozen_string_literal: true
class ContactNetwork < ApplicationRecord
FORMAT_RE = /\A[^[:space:]]+(.*[^[:space:]]+)?\z/.freeze
################
# Associations #
################
@ -13,15 +11,9 @@ class ContactNetwork < ApplicationRecord
# Validations #
###############
validates :codename,
presence: true,
codename: true,
uniqueness: { case_sensitive: false }
validates :codename, codename: true, uniqueness: { case_sensitive: false }
validates :name,
presence: true,
length: { in: 1..255 },
format: FORMAT_RE
validates :name, good_small_text: true
###########
# Methods #

View file

@ -1,8 +1,6 @@
# frozen_string_literal: true
class RegionalOffice < ApplicationRecord
FORMAT_RE = /\A[^[:space:]]+(.*[^[:space:]]+)?\z/.freeze
################
# Associations #
################
@ -15,9 +13,5 @@ class RegionalOffice < ApplicationRecord
validates :federal_subject, uniqueness: true
validates :name,
presence: true,
uniqueness: true,
length: { in: 1..255 },
format: { with: FORMAT_RE }
validates :name, good_small_text: true, uniqueness: true
end

View file

@ -1,8 +1,6 @@
# frozen_string_literal: true
class RelationStatus < ApplicationRecord
FORMAT_RE = /\A[^[:space:]]+(.*[^[:space:]]+)?\z/.freeze
################
# Associations #
################
@ -17,16 +15,9 @@ class RelationStatus < ApplicationRecord
# Validations #
###############
validates :codename,
presence: true,
codename: true,
uniqueness: { case_sensitive: false }
validates :codename, codename: true, uniqueness: { case_sensitive: false }
validates :name,
presence: true,
length: { in: 1..255 },
format: FORMAT_RE,
uniqueness: true
validates :name, good_small_text: true, uniqueness: true
###########
# Methods #

View file

@ -1,8 +1,6 @@
# frozen_string_literal: true
class RelationTransition < ApplicationRecord
FORMAT_RE = /\A[^[:space:]]+(.*[^[:space:]]+)?\z/.freeze
################
# Associations #
################
@ -19,11 +17,7 @@ class RelationTransition < ApplicationRecord
# Validations #
###############
validates :name,
presence: true,
length: { in: 1..255 },
format: FORMAT_RE,
uniqueness: true
validates :name, good_small_text: true, uniqueness: true
validate :statuses_are_not_equal