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

View file

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

View file

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

View file

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