A data validation and formatting library for JavaScript that supports both browser and Node.js. Version 1.6.0 includes chainable schema definitions for strings, numbers, booleans, objects, and arrays with support for required fields, defaults, min/max, regex patterns, custom error messages, and value formatting. It offers a try-catch validate method and a silent validate mode that returns error and value. The library is lightweight (~21 kB, 4.6 kB gzipped) and supports IE 11 and modern browsers. Release cadence is low (last update September 2020). Differentiators include flexible nested schema definitions, chainable methods without order restrictions, and easy custom error messages.
npm install racoon-jsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use validateSilent to avoid try-catch and get both error and cleaned value.
Always check error before using value. If you need partial data, consider wrapping validate in try-catch.
Chain .error() after each .min(), .max(), etc. to set specific messages per constraint.
Manually handle empty strings or zeros in your data before validation if you want defaults for those.
Use import racoon from 'racoon-js' or set esModuleInterop: true in tsconfig.json.
Ensure input age is a number (e.g., parseInt(age)) before validation.
Ensure the schema variable is assigned correctly by calling racoon.object({...}) first.No dependency data recorded yet.