Comment

Comment by suref

I built something similar for my latest webapp to validate json-requests in python, the syntax is like this:

    {
        "content": Required(str),
        "username": Required(str, validate=username_is_ok, transform=lambda x: x.lower(), 
                   fail_message="Username isn't valid"),
        "message": Optional(str),
        "some_list": Required({
            "name": Required(str),
            "date": Required(str)
        }, is_list=True)
    }
Then I can provide this in a hook to the request method.
parent suref 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton