Skip to content
Dmitry Sheiko's Web Development Blog
Blog Books About me

Validating Function Arguments in JavaScript: The Smart Way

Clean Code JavaScript May 23, 2019
Validating Function Arguments in JavaScript: The Smart Way

In software engineering we try to discover and eliminate bugs as soon as possible. One of most important heuristics here is validation of input/output on functions and methods. If you are going with TypeScript or Flow, you are fine. But if not? Then we have to manually validate at least input (arguments). But what would be the best way doing it?

GitHub Discussions
comments
Facebook LinkedIn icon X Reddit

Labels

AI (1) API Integration (2) Clean Code (4) CMS (6) CSS (3) Design Patterns (4) Developer Tools (8) JavaScript (19) PHP (4) React (5) RWD (3) Software Architecture (2) Software Design (15) Testing & QA (8) Thoughts & Opinions (12) Web Standards (13)

My github

Puppetry

puppetry

Web testing solution for non-developers on top of Puppeteer and Jest

wwwgrep

Web scraping library for Node.js

bycontract

Argument validation library based on JSDOC syntax

boilerplate

A collection of 20 frontend and full-stack starter templates covering React, Vue, Svelte, SolidJS, Webpack, Vite, Rspack, TypeScript, and more

extras

Type manipulation utility-belt bringing JavaScript-like development experience to PHP

My gists

Custom ESLint Rules: Enforcing Consistent Inner Spacing (eslint@^9)
Service-worker to prefetch remote images (with expiration) and respond with fallback one when image cannot be fetched
Example of pre-commit GIT hook for a PHP-based project

My codepens

Fancy Modal Window built with CSS only
Conditional Media Query Mixin
Controls for Youtube embedded video
Scroll top with a transition effect

Who's the dude?

Dmitry Sheiko
Dmitry Sheiko is a web-developer living and working in Frankfurt am Main, DE

Elsewhere

X Twitter LinkedIn icon LinkedIn GitHub Github CodePen Codepen SlideShare Slideshare Stack Overflow Stackoverflow

Credits

material.io/tools/icons simpleicons.org
  • Copyright © 2003–2026
  • Dmitry Sheiko
  • •
  • Contact me
  • •
  • Article RSS feed