Type-safe data validation and sanitization for MongoDB update $set operations, built on top of the validata validation library. Current stable version is 1.1.1. It provides a set of checkers (isObjectSet, isString, maybeString, isNumber, asNumber) that validate and coerce data before applying it to MongoDB $set updates, supporting both nested object structures and dot-notation paths. Unlike generic validators, it is specifically designed to match MongoDB's update semantics, including optional fields, coercion, and rejection of unexpected properties. It ships with TypeScript definitions and has a moderate release cadence.
npm install validata-mongoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates type-safe validation of MongoDB $set data using isObjectSet with nested objects and dot-notation.
Ensure the input object does not contain properties not defined in the schema, or use a more lenient checker if needed.
Use dot-notation only for properties that exist in the schema's nested structure.
wrap the data object in an arrow function: () => ({ ... })N/A
import { check } from 'validata';Remove the unexpected property or add it to the schema.
Change check(myCheck, { ... }) to check(myCheck, () => ({ ... }))