express-validator is a server-side input validation library designed specifically for Express.js applications. It provides middleware that validates and sanitizes incoming HTTP request data against developer-defined rules, collecting all validation failures into a single array for simultaneous error reporting rather than failing on the first error.
The library offers a chainable validation API where rules are built by chaining methods on a validation chain object, enabling declarative specification of multiple validators and sanitizers for a single request field. Each validation chain operates on a specific request field (such as body, query, or params), maintaining a context that tracks the field name, location, and validation state throughout execution. Validation rules can also be defined declaratively using a schema object that maps field names to validation and sanitization configurations, separating rule definition from application logic.
The library wraps and exposes the validator.js library's validation and sanitization functions as chainable methods, providing a consistent interface for common validation operations. Validation rules are defined as Express middleware functions that compose with other middleware in the request handling pipeline, allowing validation to be integrated directly into route definitions. The library also provides sanitization middleware that cleans and transforms request field values by applying sanitization functions before route handlers execute.