This commit is contained in:
Martin Lensment 2015-07-09 13:04:16 +03:00
parent 55b746a428
commit bf2c0c6bb7
2 changed files with 0 additions and 13 deletions

View file

@ -19,6 +19,5 @@ class Admin::BlockedDomainsController < AdminController
flash.now[:alert] = I18n.t('failed_to_update_record')
render :index
end
end
end

View file

@ -1,17 +1,11 @@
class DomainNameValidator < ActiveModel::EachValidator
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
def validate_each(record, attribute, value)
if !self.class.validate_format(value)
record.errors[attribute] << (options[:message] || record.errors.generate_message(attribute, :invalid))
elsif !self.class.validate_blocked(value)
record.errors.add(attribute, (options[:message] || record.errors.generate_message(attribute, :blocked)))
# elsif !self.class.validate_reservation(value)
# record.errors.add(attribute, (options[:message] || record.errors.generate_message(attribute, :reserved)))
end
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
class << self
def validate_format(value)
@ -41,11 +35,5 @@ class DomainNameValidator < ActiveModel::EachValidator
return true unless value
BlockedDomain.where("names @> ?::varchar[]", "{#{value}}").count == 0
end
# def validate_reservation(record, value)
# return true unless value
# return true if record.reserved_pw == record.auth_info
# !ReservedDomain.exists?(name: value.mb_chars.downcase.strip)
# end
end
end