Skip to content

Support namedtuple #364

Closed
Closed
@ejconlon

Description

@ejconlon

Though json doesn't treat namedtuple instances as objects, simplejson does. It would be useful to be able to validate object graphs with namedtuple instances like dict instances.

The main complication here is that Validator's is_type and DEFAULT_TYPES and very subclass-oriented, and detecting a namedtuple is a matter of duck-typing (hasattr(instance.__class__, '_fields') or the less-restrictive hasattr(instance, '_asdict')). From there I'm not quite sure where to make the change to traverse object items.

Thanks for your consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions