b-validate is a JavaScript and TypeScript validation library offering a flexible, chainable API for data validation. It supports basic type and value checks, as well as complex schema-based validation for objects, including asynchronous validation logic. Since its rewrite in TypeScript in version 1.4.0, it ships with robust type definitions. The library is currently stable at version 1.5.3, with releases occurring periodically to address bugs and introduce minor enhancements rather than a fixed cadence. Key differentiators include its fluent, chainable API for individual validations, comprehensive schema validation capabilities, support for custom synchronous and asynchronous validators, and granular control over validation messages, including global configuration and locale-specific message templates. It aims to provide a comprehensive validation solution for both simple and complex data structures in web and Node.js environments.
npm install b-validateVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates both basic chainable validation and complex schema validation, including custom and asynchronous validators, and optional locale loading for validation messages.
Ensure your build tooling correctly handles TypeScript output and ESM imports. If experiencing issues, verify import paths and how your bundler resolves the 'exports' field in package.json.
Upgrade to version 1.3.4 or later to ensure custom validator messages are displayed correctly. If an upgrade is not possible, ensure your `callback` function is always called with a string message.
Always test your message customization in the context you intend. For highly localized or specific messages, prefer passing options directly to the validator instance or schema. Use global config for application-wide defaults.
Use ESM import syntax: `import bv, { Schema } from 'b-validate';`. If stuck with CommonJS, some bundlers might allow `const bv = require('b-validate').default;` but it's not officially supported for all entry points.Upgrade `b-validate` to version 1.3.4 or higher. If upgrading is not feasible, ensure that any custom `callback` function always receives a string as its argument for the error message.
Ensure your bundler (e.g., Webpack, Rollup) is configured to handle ESM modules and resolve package `exports`. If using Node.js directly, ensure you are running in an ESM context. You might need to adjust import paths or configure your bundler to alias the `es` path.
No dependency data recorded yet.