map-schema is a Node.js library for validating and normalizing JavaScript objects against a defined schema. Current version 0.3.0 (sporadically updated, last release 2018) provides a chainable API to define fields with type checks, default values, custom normalizers, and validators. It supports validation error collection and is designed for scenarios like package.json normalization. Alternatives like Joi or Yup offer more features but map-schema is simpler for basic use.
npm install map-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a schema with default values and a custom validator, then normalize an object.
Clone your object before passing it if you need to preserve the original: schema.normalize(Object.assign({}, obj))Check schema.errors after calling normalize() to see any validation failures.
Use dot notation keys (e.g., 'person.name') only works if you implement custom logic; the library does not handle nesting.
Use const Schema = require('map-schema');No dependency data recorded yet.