Mongoose schema plugin that adds array validation constraints such as minItems, maxItems, and uniqueItems to your schemas. Version 1.0.3 is the latest and only stable release; no active development seen. Unlike manual validation in middleware, this plugin integrates directly into schema path options. Requires Mongoose as a peer dependency. Note that the plugin must be applied via schema.plugin().
npm install mongoose-array-validatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Mongoose schema with array validations (minItems, maxItems, uniqueItems) using the plugin and validates a document with duplicate values.
Ensure Mongoose version is 4.x, 5.x, or 6.x installed.
Consider migrating to Mongoose built-in array validators or custom middleware.
Always call schema.plugin(arrayValidator) before compiling the model.
Use { value: ..., message: props => `...` } exactly.Change import to const arrayValidator = require('mongoose-array-validator');Ensure the path type is an array (e.g., [String]) and schema.plugin(arrayValidator) is called.
Use property named 'message' in the options object.