validatorjs/validator.js ? reverse-engineered prompt

Reverse engineered prompt

Build me a JavaScript library for validating and cleaning up strings.

I want it to work in Node and in the browser, and it should only accept strings, so if something else is passed in it should fail clearly. The library should include a bunch of common checks like email, URL, numbers, dates, credit cards, IP addresses, hex, alphanumeric text, and other everyday validators, plus a few sanitizing helpers for trimming or escaping unsafe text. It should be easy to use with either one main import or by importing just one validator at a time.

Please make it feel polished, with good test coverage, clear error handling, and a browser friendly build too. If you need to look up the current behavior for any tricky validation rules, feel free to check the docs online.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab