I came up with a fairly slick solution to the June 6 2026 Daily Challenge inspired by Joi and other schema validation tools. In Python:
def is_valid_schema(obj):
Roles = Schema().string_enum(
“user”, “creator”, “moderator”, “staff”, “admin”
)
UserProfile = Schema().object({
"username": Schema().string(),
"posts": Schema().number(),
"verified": Schema().boolean(),
"role": Roles,
"supporter": Schema().optional().boolean(),
"badges": Schema().array(Schema().string())
})
validator = Schema().object({
"users": Schema().array(UserProfile)
})
return validator.validate(obj)
Implementing the Schema class is left as an exercise for the reader ![]()