Skip to content

Need to implement validation for input data in create_post() and update_post() #2

@noumxn

Description

@noumxn
  • Currently, in the create_post() and update_post() functions, we don't have error handling for incase the user provides input json data with any key other that 'msg'.
  • For example, the request body is { "text": "Hello world!" }, this would not be valid, and a 400 BAD_REQUEST error should be thrown.
  • A check similar to the professors code should suffice.
if 'times' not in o or not isinstance(o['times'], int) or o['times'] <= 0:
        return { 'err': 'expected positive int-valued "times" field' }, 400

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions