A lightweight JavaScript object validator supporting data type checks (isNumeric, isEmail, etc.), value/length ranges, and custom validation functions. Version 2.0.2 targets Node.js and browsers, is not actively maintained (last release 2016), and offers a simple synchronous API. It reuses validator.js for data type checking and requires manual mandatory field handling. Differentiators include minimal dependencies and straightforward integration for basic object validation.
npm install sql-validatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: import, create validator with mandatory map, define validation rules, and validate data.
Consider migrating to class-validator or joi for active maintenance.
Ensure mandatory fields exist in data even if optional; adjust mandatoryMap accordingly.
Use map format for future-proof code; chaining is currently supported but deprecated.
Call validator.addValidations(customValidators) before validation.
Wrap validation in try/catch for error handling; no async support planned.
Use 'const Validator = require('sql-validator').default' or 'import Validator from 'sql-validator'; then 'new Validator(...)'.Ensure you have instantiated with 'new Validator(mandatoryMap)' and call instance.isValid(...).
Inspect the value of the invalid key and adjust data or validation rules accordingly.
Call instance.addValidations(...) after creation.