Skip to main content

ValidatedDict

This trait defines a common interface for dictionary-like structures that support validated data retrieval and iteration. It provides methods for accessing items via lookup paths, determining if the source is a Python attribute access, and iterating over key-value pairs using a consumer pattern. The trait also includes functionality to track the last processed key, which is primarily used for error handling during partial validation modes.

Methods


get_item()

def get_item(
key: &LookupPath
) - > ValResult< Option< Self::Item > >

Retrieves a specific item from the dictionary using a lookup path, returning the item if found or None if the key does not exist.

Parameters

NameTypeDescription
key&LookupPathThe hierarchical path or key used to locate the desired item within the dictionary structure.

Returns

TypeDescription
ValResult< Option< Self::Item > >The item associated with the provided lookup path, or None if the path is not present in the dictionary.

is_py_get_attr()

def is_py_get_attr() - > bool

Indicates whether the dictionary access should be treated as a Python attribute lookup rather than a standard key-based lookup.

Returns

TypeDescription
boolTrue if the dictionary represents a Python object's attributes, False otherwise.

iterate()

def iterate(
consumer: [ConsumeIterator](consumeiterator.md?sid=input_input_abstract_consumeiterator)
) - > ValResult< R >

Iterates over the dictionary's key-value pairs and applies a consumer function to process each entry.

Parameters

NameTypeDescription
consumer[ConsumeIterator](consumeiterator.md?sid=input_input_abstract_consumeiterator)An iterator consumer that processes the key-value pairs and produces a final output value.

Returns

TypeDescription
ValResult< R >The result produced by the consumer after processing the dictionary entries.

last_key()

def last_key() - > Option< Self::Key >

Retrieves the most recently accessed or processed key, typically used in partial validation mode to track where errors occurred.

Returns

TypeDescription
Option< Self::Key >The last key processed by the dictionary, or None if no keys have been accessed.