JavaScript Object Validators

Updated Sep 10, 2021#javascript#libs#lists

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 - 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 - This library validates and sanitizes strings only, validate all sorts of concerns related to string and convert if possible.
  • Yup - 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 - A JSON Schema validator for Node.js and browser, implements full JSON Schema, asynchronous loading of referenced schemas during compilation, etc.
  • 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.