Created
January 20, 2023 06:17
-
-
Save rdammkoehler/43fd463df5b4ca573695a9a35e6e4896 to your computer and use it in GitHub Desktop.
Example Validation using Exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validate(httpReq) { | |
const body = JSON.parse(httpReq.body); | |
if (!body.hasOwnProperty('name')) { | |
throw new Error('invalid request'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment