Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow maps to convert into objects when missing optional attributes are not compatible #139

Merged

Commits on Oct 19, 2022

  1. convert: Only consider present map elements when converting to object…

    … type
    
    Optional object attributes give us a new situation to consider here: the
    source element type might not be compatible with all of the optional
    attributes of a target object type, but that doesn't matter if the given
    map doesn't include an element corresponding with the mismatching
    attributes.
    
    This is a bit awkward because we need to first allow the type conversion
    logic to produce a valid conversion but then catch the attribute mismatch
    only when applying the conversion function to the value. This is
    effectively the same sequence of events that happens when converting from
    string to number or string to bool: we optimistally assume that a
    conversion will succeed when looking only at types, and then catch the
    error dynamically once we have a final value to check.
    liamcervante authored and apparentlymart committed Oct 19, 2022
    Copy the full SHA
    ac3f431 View commit details
    Browse the repository at this point in the history