image

JavaScript data validation libraries

Notable JavaScript libraries for validating data at runtime

Data validation libraries are designed for validating data at runtime, so it throws or returns detailed runtime errors for you or your end users. This is especially useful in situations like accepting arbitrary input in a REST or GraphQL API. It can even be used to validate internal data structures at runtime when needed.


Joi

image

joi.dev

The most powerful schema description language and data validator for JavaScript. Joi lets you describe your data using a simple, intuitive, and readable language.

Validator.js

image

github.com

This library validates and sanitizes strings only, validate all sorts of concerns related to string and convert if possible.

Yup

image

github.com

Yup is a JavaScript schema builder for value parsing and validation, heavily inspired by Joi, but leaner and built with client-side validation as its primary use-case.

Ajv

image

ajv.js.org

Ajv is a JSON Schema validator for Node.js and browser, implements full JSON Schema, asynchronous loading of referenced schemas during compilation, etc.

Superstruct

image

github.com

Superstruct makes it easy to define interfaces and then validate JavaScript data against them. Its type annotation API was inspired by Typescript, Flow, Go, and GraphQL, giving it a familiar and easy to understand API.