
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
@nodebysam/tiny-validation
Advanced tools
Tiny Validation is a lightweight, chainable input validation library for Node.js. Validate strings, numbers, emails, and more with ease. Example: validate(input).isEmail().isNotEmpty(). No dependencies, simple API, and perfect for quick validation needs w
A minimalistic Node.js data validation library that provides a collection of rules for validating different types of values. This library allows developers to easily chain multiple validation rules, ensuring that the input data is valid according to your custom needs.
To install Tiny Validation in your project, run the following command:
npm install @nodebysam/tiny-validation
Alternatively, if you are using Yarn:
yarn add @nodebysam/tiny-validation
Here's how you can get started using Tiny Validation.
const TinyValidation = require('@nodebysam/tiny-validation');
const Validator = TinyValidation.Validator;
const userInput = {
email: 'test@example.com',
password: 'Pass1234',
phoneNumber: '123-456-7890'
};
// Email validation
const emailValidator = new Validator(userInput.email);
emailValidator.use(TinyValidation.rules.isEmail);
// Password validation
const passwordValidator = new Validator(userInput.password);
passwordValidator
.use(TinyValidation.rules.isMinLength, 8)
.use(TinyValidation.rules.isStrongPassword);
// Phone number validation
const phoneValidator = new Validator(userInput.phoneNumber);
phoneValidator.use(TinyValidation.rules.isPhoneNumber);
if (emailValidator.isValid() && passwordValidator.isValid() && phoneValidator.isValid()) {
console.log('All inputs are valid!');
} else {
console.error('Validation failed!');
console.log('Errors:', {
emailErrors: emailValidator.getErrors(),
passwordErrors: passwordValidator.getErrors(),
phoneErrors: phoneValidator.getErrors()
});
}
You can chain these validation rules using the .use() method, passing the value you want to validate and any neccessary parameters.
Here are the available validation rules in Tiny Validation (more rules to come soon):
Tiny Validation includes unit tests to ensure that everything works as expected. To run the tests, follow these steps:
npm install
npm test
This will run the unit tests using Ava. If everything is set up correctly, you should see the test results printed in the console.
We welcome contributions to Tiny Validation! Here's how you can help:
We will review your pull request, and if everything looks good, we'll merge it!
If you find a bug or have an idea for a new feature, feel free to open an issue on GitHub.
Tiny Validation is released under the GNU v3.0 License.
FAQs
Tiny Validation is a lightweight, chainable input validation library for Node.js. Validate strings, numbers, emails, and more with ease. Example: validate(input).isEmail().isNotEmpty(). No dependencies, simple API, and perfect for quick validation needs w
We found that @nodebysam/tiny-validation demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.