Skip to content

Instantly share code, notes, and snippets.

@rdammkoehler
Created January 20, 2023 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdammkoehler/43fd463df5b4ca573695a9a35e6e4896 to your computer and use it in GitHub Desktop.
Save rdammkoehler/43fd463df5b4ca573695a9a35e6e4896 to your computer and use it in GitHub Desktop.
Example Validation using Exceptions
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