mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 15:22:58 +00:00
type cast value before blank check for invalid values
This commit is contained in:
@@ -10,6 +10,8 @@ module ValidatesTimeliness
|
||||
when :datetime
|
||||
value.to_time.in_time_zone
|
||||
end
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
def dummy_time(value)
|
||||
|
||||
@@ -35,10 +35,10 @@ module ValidatesTimeliness
|
||||
raw_value = attribute_raw_value(record, attr_name) || value
|
||||
return if (@allow_nil && raw_value.nil?) || (@allow_blank && raw_value.blank?)
|
||||
|
||||
return record.errors.add(attr_name, :"invalid_#{@type}") if value.blank?
|
||||
|
||||
value = type_cast(value)
|
||||
|
||||
return record.errors.add(attr_name, :"invalid_#{@type}") if value.blank?
|
||||
|
||||
@check_restrictions.each do |restriction|
|
||||
begin
|
||||
restriction_value = type_cast(evaluate_option_value(options[restriction], record))
|
||||
|
||||
Reference in New Issue
Block a user