mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-24 14:56:43 +00:00
use value as raw_value if object doesn't have _before_type_cast method
This commit is contained in:
parent
515a1b3126
commit
fae38cfecd
@ -35,7 +35,7 @@ module ValidatesTimeliness
|
|||||||
|
|
||||||
def call(record, attr_name, value)
|
def call(record, attr_name, value)
|
||||||
value = record.class.parse_date_time(value, type, false) if value.is_a?(String)
|
value = record.class.parse_date_time(value, type, false) if value.is_a?(String)
|
||||||
raw_value = raw_value(record, attr_name)
|
raw_value = raw_value(record, attr_name) || value
|
||||||
|
|
||||||
return if (raw_value.nil? && configuration[:allow_nil]) || (raw_value.blank? && configuration[:allow_blank])
|
return if (raw_value.nil? && configuration[:allow_nil]) || (raw_value.blank? && configuration[:allow_blank])
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ module ValidatesTimeliness
|
|||||||
private
|
private
|
||||||
|
|
||||||
def raw_value(record, attr_name)
|
def raw_value(record, attr_name)
|
||||||
record.send("#{attr_name}_before_type_cast")
|
record.send("#{attr_name}_before_type_cast") rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_restrictions(record, attr_name, value)
|
def validate_restrictions(record, attr_name, value)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user