Don’t use unless
This commit is contained in:
parent
8c73851cec
commit
7c34807f46
90 changed files with 164 additions and 157 deletions
|
@ -8,7 +8,7 @@ class FileSizeValidator < ActiveModel::EachValidator
|
|||
|
||||
def initialize(options)
|
||||
if range = (options.delete(:in) || options.delete(:within))
|
||||
raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range)
|
||||
raise ArgumentError, ":in and :within must be a Range" if !range.is_a?(Range)
|
||||
options[:minimum], options[:maximum] = range.begin, range.end
|
||||
options[:maximum] -= 1 if range.exclude_end?
|
||||
end
|
||||
|
@ -26,19 +26,19 @@ class FileSizeValidator < ActiveModel::EachValidator
|
|||
keys.each do |key|
|
||||
value = options[key]
|
||||
|
||||
unless (value.is_a?(Integer) && value >= 0) || value.is_a?(Symbol)
|
||||
if !(value.is_a?(Integer) && value >= 0) && !value.is_a?(Symbol)
|
||||
raise ArgumentError, ":#{key} must be a nonnegative Integer or symbol"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
|
||||
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") if !value.kind_of? CarrierWave::Uploader::Base
|
||||
|
||||
value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
|
||||
|
||||
CHECKS.each do |key, validity_check|
|
||||
next unless check_value = options[key]
|
||||
next if !check_value = options[key]
|
||||
|
||||
check_value =
|
||||
case check_value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue