lib/avromatic/model/attributes.rb in avromatic-0.5.0 vs lib/avromatic/model/attributes.rb in avromatic-0.6.0
- old
+ new
@@ -74,11 +74,11 @@
add_required_validation(field)
end
def add_required_validation(field)
- if required?(field) && field.default.nil?
+ if required?(field) && field.default == :no_default
validates(field.name, presence: true)
end
end
# An optional field is represented as a union where the first member
@@ -135,10 +135,11 @@
custom_type = Avromatic.type_registry.fetch(field)
coercer = custom_type.deserializer
options[:coercer] = coercer if coercer
- if field.default
+ # See: https://github.com/dasch/avro_turf/pull/36
+ if field.default != :no_default
options.merge!(default: default_for(field.default), lazy: true)
end
options
end