I've made an update to the library to add mirror-structure rules that literally resemble the shape of your data.
from validatedata import validate_data
data = { "user": { "name": "Alice", "email": "alice@example.com", "profile": { "age": 28, "bio": " Python enthusiast ", "tags": ["dev", "python"] } } }
# Mirror rule – clean and readable rule = { "user": { "name": "str|min:3|max:50", "email": "email", "profile": { "age": "int|between:13,120", "bio": "str|strip|max:500", "tags": "list|unique|min:1" } } }
result = validate_data(data, rule, mutate=True)
if result.ok: print("Valid!") print(result.data) # With mutate=True you even get cleaned data back in the same shape else: print(result.errors)