Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
tbconroy committed Jul 19, 2024
1 parent 1649f44 commit 455b5c0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/typed/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def serialize(struct)
def deserialize_from_creation_params(creation_params)
results = schema.fields.map do |field|
value = creation_params.fetch(field.name, nil)

if value.nil? && !field.default.nil?
Success.new(Validations::ValidatedValue.new(name: field.name, value: field.default))
elsif value.nil? || field.works_with?(value)
Expand All @@ -47,6 +48,7 @@ def deserialize_from_creation_params(creation_params)
next if sub_type.raw_type.equal?(NilClass)

coercion_result = Coercion.coerce(type: sub_type, value: value)

if coercion_result.success?
validated_value = field.validate(coercion_result.payload)

Expand Down

0 comments on commit 455b5c0

Please sign in to comment.