We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 10c1027 commit e3bc037Copy full SHA for e3bc037
1 file changed
app/lib/flex/attributes.rb
@@ -49,7 +49,12 @@ def memorable_date_attribute(name, options)
49
value = send(name)
50
raw_value = read_attribute_before_type_cast(name)
51
52
- if raw_value.present? && value.nil?
+ # If model.<attribute> is nil, but model.<attribute>_before_type_cast is not nil,
53
+ # that means the application failed to cast the value to the appropriate type in
54
+ # order to complete the attribute assignment. This means the original value
55
+ # is invalid.
56
+ did_type_cast_fail = value.nil? && raw_value.present?
57
+ if did_type_cast_fail
58
errors.add(name, :invalid_memorable_date)
59
end
60
0 commit comments