validate-any v1.3.2
Validate Any
Validate Any is a type validator mainly for Typescript (also works with Javascript) available here. Ever faced those issues where you're trying to make sure a type any
is an instance of an interface? This is the issue this package was designed to solve. With this package, you can safely assert the type for an object and return customised errors if the types are incorrect.
Full Documentation is available here.
Motivation
I hate it when I am unable to validate the request types of JSON objects in Express requests. I wanted to be able to reject a request before my request handlers used the request body. I also didn't like casting the type of the body in the request.
Features
validate
function to validate the data type of a variable- Validate Any can read the function types of
- Strings
- Numbers
- Booleans
- Undefined
- Null
- Lists
- Objects
- Classes
- Validate Any is built to automatically return you the typescript annotations generated by the schema you pass, in the
data
property - Detailed error messages to tell you where any validation errors occured
- API Middleware to simplify its usage with Express or NextJS
Testing
Validate Any's individual validators are tested with Jest. To run the tests, run the command
$ npm run test