<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/express-validator---part-1-why-your-api-should-never-trust-client-input-cnibyjrnd" -->

---
title: Express Validator - Part 1: Why Your API Should Never...
description: This introductory piece explains why backend APIs must never trust client-submitted data, using Express.js as the example framework. It walks through the risks...
canonical: https://daily.dev/posts/express-validator---part-1-why-your-api-should-never-trust-client-input-cnibyjrnd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Express Validator - Part 1: Why Your API Should Never Trust Client Input | daily.dev
og:description: This introductory piece explains why backend APIs must never trust client-submitted data, using Express.js as the example framework. It walks through the risks...
og:url: https://daily.dev/posts/express-validator---part-1-why-your-api-should-never-trust-client-input-cnibyjrnd
og:image: https://api.daily.dev/og/posts/CniByJrnd.png
og:image:alt: Express Validator - Part 1: Why Your API Should Never Trust Client Input
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Express Validator - Part 1: Why Your API Should Never Trust Client Input

**[Medium](https://daily.dev/sources/medium_js)** · 7 min read · 1 upvotes · 0 comments

## Summary

This introductory piece explains why backend APIs must never trust client-submitted data, using Express.js as the example framework. It walks through the risks of skipping request validation, such as messy controllers, duplicated validation logic, and inconsistent error handling, and introduces Express Validator as a middleware solution that validates data across the request body, params, query, and headers. It clarifies that Express Validator is one layer of defense, not a full security solution, and distinguishes it from database-level validation. The piece closes by previewing a follow-up part that will build a full validation architecture using Express Validator.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@mohammadadnanfaiz/express-validator-part-1-why-your-api-should-never-trust-client-input-68d108d2cdfe>

## Questions this post answers

### Why isn't frontend validation enough for an API, and do I still need backend validation?

Frontend validation only improves user experience but is not a security boundary, since anyone can bypass it using Postman, cURL, browser dev tools, custom scripts, or another server. The backend receives raw HTTP requests with no guarantee they came from a trusted frontend, so it must independently enforce its own validation rules for data integrity and application safety.

_daily.dev surfaces backend security practices for developers hardening APIs against untrusted client input._

### What does express-validator actually validate in an Express.js request?

Express Validator can validate data from multiple parts of an HTTP request, not just the JSON body: body() for request body fields, param() for route parameters like an id in /users/123, query() for query string values like page in /products?page=2, and header() for request headers such as Authorization. It provides validators like isEmail(), isLength(), isInt(), isFloat(), isIn(), and matches().

_developers structuring express.js validation logic can find practical middleware patterns on daily.dev._

### Does express-validator replace the need for database-level validation?

No, express-validator and database validation operate at different layers and one does not replace the other. Express Validator rejects malformed requests early in the pipeline, before they reach the controller or business logic, while database validation acts as an additional safeguard once data is being persisted, catching anything that slips through earlier layers.

_daily.dev helps backend engineers weigh layered validation strategies before committing to an API architecture._

## Similar posts on daily.dev

- [Express-Validator in Express.js: From Messy Controllers to Clean APIs.](https://daily.dev/posts/express-validator-in-express-js-from-messy-controllers-to-clean-apis--fxe66zn6k) · Medium · 3 upvotes · 0 comments
- [How to Build Secure-by-Default Node.js APIs](https://daily.dev/posts/how-to-build-secure-by-default-node-js-apis-kgzyotifm) · freeCodeCamp · 10 upvotes · 0 comments
- [Stop telling people to sanitize user input](https://daily.dev/posts/stop-telling-people-to-sanitize-user-input-igpjyfawq) · unixsheikh.com · 51 upvotes · 9 comments
- [Stop fighting forms: The schema-driven approach to validation](https://daily.dev/posts/stop-fighting-forms-the-schema-driven-approach-to-validation-8vq511w0o) · LogRocket · 1 upvotes · 0 comments
- [A Practical Guide to Secure Authentication for Developers](https://daily.dev/posts/a-practical-guide-to-secure-authentication-for-developers-p5rufwxgq) · SitePoint · 0 upvotes · 0 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#nodejs](https://daily.dev/tags/nodejs), [#appsec](https://daily.dev/tags/appsec)

[View this post on daily.dev](https://daily.dev/posts/express-validator---part-1-why-your-api-should-never-trust-client-input-cnibyjrnd)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Express Validator - Part 1: Why Your API Should Never Trust Client Input","url":"https://daily.dev/posts/express-validator---part-1-why-your-api-should-never-trust-client-input-cnibyjrnd","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/express-validator---part-1-why-your-api-should-never-trust-client-input-cnibyjrnd"},"datePublished":"2026-09-11T20:15:23.414Z","dateModified":"2026-09-11T20:28:43.792Z","description":"This introductory piece explains why backend APIs must never trust client-submitted data, using Express.js as the example framework. It walks through the risks...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/1ff91e1c5abce2ec276a12c153b9771e?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/1ff91e1c5abce2ec276a12c153b9771e?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/express-validator---part-1-why-your-api-should-never-trust-client-input-cnibyjrnd","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"architecture,nodejs,appsec","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Express Validator - Part 1: Why Your API Should Never Trust Client Input"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/express-validator---part-1-why-your-api-should-never-trust-client-input-cnibyjrnd#faq","mainEntity":[{"@type":"Question","name":"Why isn't frontend validation enough for an API, and do I still need backend validation?","acceptedAnswer":{"@type":"Answer","text":"Frontend validation only improves user experience but is not a security boundary, since anyone can bypass it using Postman, cURL, browser dev tools, custom scripts, or another server. The backend receives raw HTTP requests with no guarantee they came from a trusted frontend, so it must independently enforce its own validation rules for data integrity and application safety. daily.dev surfaces backend security practices for developers hardening APIs against untrusted client input."}},{"@type":"Question","name":"What does express-validator actually validate in an Express.js request?","acceptedAnswer":{"@type":"Answer","text":"Express Validator can validate data from multiple parts of an HTTP request, not just the JSON body: body() for request body fields, param() for route parameters like an id in /users/123, query() for query string values like page in /products?page=2, and header() for request headers such as Authorization. It provides validators like isEmail(), isLength(), isInt(), isFloat(), isIn(), and matches(). developers structuring express.js validation logic can find practical middleware patterns on daily.dev."}},{"@type":"Question","name":"Does express-validator replace the need for database-level validation?","acceptedAnswer":{"@type":"Answer","text":"No, express-validator and database validation operate at different layers and one does not replace the other. Express Validator rejects malformed requests early in the pipeline, before they reach the controller or business logic, while database validation acts as an additional safeguard once data is being persisted, catching anything that slips through earlier layers. daily.dev helps backend engineers weigh layered validation strategies before committing to an API architecture."}}]}
```

