New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

robust-validator

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

robust-validator

Rule-based data validation library

  • 2.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
151
increased by42.45%
Maintainers
0
Weekly downloads
 
Created
Source



Robust Validator
npm version

Rule-based data validation in JS. Extendable, function-oriented, i18n-supported

Documentation

💡 Why?

Discovering a data validation library that seamlessly combines ease of use, the ability to store validation rules for future use, and robust internationalization (i18n) support is a formidable challenge. While numerous data validation libraries exist, finding one that fulfills all these criteria is often elusive. Some libraries that do meet these requirements are unfortunately no longer actively maintained.

Robust Validator was born out of the need for a versatile data validation solution that not only simplifies the validation process but also empowers developers with the flexibility to preserve and reuse validation rules. This library aims to bridge the gap by offering a user-friendly experience, ensuring your validation needs are met comprehensively.

Why choose Robust Validator? It's more than just a data validation tool; it's a commitment to providing a reliable, well-maintained, and feature-rich solution for developers who value simplicity and effectiveness in their projects.

🤞 Principles

I decided on some fundamental rules while building this library:

  • ✅︎ Every validation rule should be an independent function.
  • ✅︎ Every validation rule should be able to be used separately
  • ✅︎ All validation definition should be able to be stored anywhere (database, memory, configuration files, 3rd party API, etc) to be used later.
  • ✅︎ All validation rules should be able to be used in different languages.
  • ✅︎ Contribution to the rule set should be easy.
  • ✅︎ Should be well-documented.

🏃 Installation

The library can be installed into an existing project:

$ npm install --save robust-validator

💪 Usage

Using robust-validator is very simple.

You should just call the validate() function with data and the definition.

import { validate, setLocales, en } from "robust-validator";

setLocales(en);

const data = {
  email: "not-a-valid-email",
  name: "John",
  surname: "Doe",
};

const definition = {
  email: "required|email",
  name: "required|min:1|max:50",
  surname: "required|min:1|max:50",
};

const result = await validate(data, definition);
console.log(result);

🤝 Contributors

Made with contrib.rocks.

⚖️ License

MIT License

Keywords

FAQs

Package last updated on 03 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc