Download Latest Version v7.2.1 source code.tar.gz (708.3 kB)
Email in envelope

Get an email when there's a new version of express-validator

Home / v7.0.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2023-04-15 2.6 kB
v7.0.0 source code.tar.gz 2023-04-15 693.2 kB
v7.0.0 source code.zip 2023-04-15 945.0 kB
Totals: 3 Items   1.6 MB 0

๐Ÿš€ ๐Ÿ™Œ First major version in almost 4 years! ๐Ÿš€ ๐Ÿคฏ Thanks everybody for having the patience. Hopefully this version brings many improvements to your developer experience!

Breaking changes ๐Ÿ’ฅ

  • Minimum supported Node.js version is now 14+
  • Removed deprecated APIs - [#993]
    • Import paths express-validator/check and express-validator/filter
    • Sanitization-only middlewares (e.g. sanitize(), sanitizeBody(), etc)
    • Deprecated TypeScript types (ValidationParamSchema and ValidationSchema)
  • isObject() validator now assumes options.strict = true by default
  • Validation errors changed shape
    • Field validation errors param property has been renamed to path
    • oneOf() validation errors no longer have a param: '_error' property
  • (TypeScript only) The ValidationError type is now a discriminated union, it might be necessary to use switch or if statements to check that you're dealing with the type that you want to debug/format
  • oneOf() signature changed: from oneOf(chains, message) to oneOf(chains, options: { message, errorType })
  • oneOf() default error structure now groups errors by their... validation group!, instead of in a flat list

Checkout the migration guide for examples on how to work around some of these: https://express-validator.github.io/docs/migration-v6-to-v7

New features โœจ

  • Added validation for no unknown fields - [#558], [#578], [#612], [#1148], [#809], [#927], [#1204]
  • Added globstars (deep wildcard) support - [#790], [#1137], [#1216]
  • Added support for multiple custom validators/sanitizers in checkSchema() - [#552], [#1180]
  • Added request-level bail - [#1100], [#1214]
  • Added a ExpressValidator class which allows adding "persistent" custom validators, sanitizers, and options - [#1077], [#1079], [#1209]
  • Added oneOf() support to .if() - [#1170]
  • Added new error types to oneOf() - [#956], [#1022]

Bug fixes ๐Ÿ›

  • Validating/sanitizing arrays no longer drops all but the first value - [#791], [#755], [#704], [#1002]
  • Added missing ko-KR to MobilePhoneLocale - [#1218], [#1219]
  • Don't silently fail when setting withMessage and not in schemas - [#664]

New Contributors

Full Changelog: https://github.com/express-validator/express-validator/compare/v6.15.0...v7.0.0

Source: README.md, updated 2023-04-15