News for hackers. Stuff that matters.
Re:Show HN: Verify JSON using minimal schema by suref on Thursday April 16, 2020 @03:47AM (#22887105)
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.
Re:Show HN: Verify JSON using minimal schema by 1f97 on Thursday April 16, 2020 @04:43AM (#22887386)
can you tell me a bit more about this? i wanted something like this for a small api i have but ended up using marshmallow to validate jsons against defined schemas which i think is a bit overkill.
Re:Show HN: Verify JSON using minimal schema by kingosticks on Thursday April 16, 2020 @05:19AM (#22887560)
If you haven't seen, these alternatives might also be helpful:

   * https://github.com/keleshev/schema
   * https://github.com/alecthomas/voluptuous
   * https://github.com/Pylons/colander
Re:Show HN: Verify JSON using minimal schema by 1f97 on Thursday April 16, 2020 @07:01AM (#22888167)
thanks, i will take a look!