Skip to main content

validate_dict

No overview available.

def validate_dict(
data: dict,
schema: dict
) - > bool

Validates that a dictionary contains all required keys and that their values match the expected data types. Use this to ensure incoming JSON payloads or configuration objects conform to a specific schema before processing.

Parameters

NameTypeDescription
datadictThe dictionary object to be validated against the schema.
schemadictA mapping of required keys to their expected Python types (e.g., { 'id': int, 'name': str }).

Returns

TypeDescription
boolReturns True if the dictionary is valid according to the schema, otherwise False.