express-validator

Express.js middleware for validating and sanitizing request data (body, params, query, headers, cookies). Built on top of validator.js. Provides a chainable API: body('email').isEmail().normalizeEmail(), param('id').isUUID(), query('page').isInt({min: 1}). Validation results collected via validationResult() or matchedData(). The de-facto standard for Express.js request validation.

Evaluated Mar 07, 2026 (0d ago) v7.x
Homepage ↗ Repo ↗ Developer Tools validation express middleware sanitization node typescript security request-validation
⚙ Agent Friendliness
69
/ 100
Can an agent use this?
🔒 Security
97
/ 100
Is it safe for agents?
⚡ Reliability
88
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
85
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
90
Secret Handling
92

Input validation library — primary security purpose is preventing injection and XSS via sanitization. escape() and normalizeEmail() sanitizers prevent common attacks. Well-maintained security-focused library.

⚡ Reliability

Uptime/SLA
92
Version Stability
88
Breaking Changes
82
Error Recovery
92
AF Security Reliability

Best When

You're building Express.js APIs and need validation middleware that integrates naturally with Express's middleware chain and validator.js's format validators.

Avoid When

You want TypeScript type inference from validation schemas or need framework-agnostic validation — use Zod instead.

Use Cases

  • Validate and sanitize request bodies in Express.js API endpoints (email format, required fields, type coercion)
  • Validate route parameters (UUID format, integer ranges) before database queries to prevent invalid queries
  • Sanitize user input (trim, escape HTML, normalize email) to prevent XSS and clean data before storage
  • Validate query string parameters for API filter/pagination endpoints with clear error messages
  • Create reusable validation chains as middleware arrays applied to multiple routes sharing the same validation rules

Not For

  • Complex nested object validation with TypeScript type safety — use Zod for type-safe schema validation with inference
  • Non-Express frameworks — use Joi or Zod directly for framework-agnostic validation
  • Schema-first validation — express-validator is imperative; Zod or Joi are schema-first for reusable schemas across frontend/backend

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No authentication — validation middleware.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Fully free, MIT licensed.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Validation chains don't reject requests — must explicitly call validationResult(req) and check for errors; missing this check means invalid data passes through
  • Sanitizers mutate req.body/params/query — use matchedData(req) instead of req.body to get only validated+sanitized data; req.body still contains original unsanitized values
  • Async validators require await inside custom() — custom validators returning promises must use the async validator pattern or return a rejected promise for errors
  • Array validation with wildcard notation: body('items.*.name').notEmpty() — wildcard validation must be set up correctly; test with array inputs
  • v7 checkSchema() API changed from v6 — schema-based validation format differs between major versions; check changelog when upgrading
  • Order of validation chains matters — sanitizers applied in chain order; withMessage() must follow the validator it applies to in the chain

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for express-validator.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-07.

6470
Packages Evaluated
26150
Need Evaluation
173
Need Re-evaluation
Community Powered