0.1.1 • Published 7 months ago

@aleksandarvasilevski/valida-js v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Valida-js

License

Description

Valida-js is a lightweight and flexible validation library for JavaScript, designed to validate various data types and structures.

Table of Contents

Installation

To install the library, you can use npm:

npm install @aleksandarvasilevski/valida-js

Usage

const { validate } = require('@aleksandarvasilevski/valida-js');

const validationData = {
  username: 'john',
  email: 'john@mail.com',
  password: '123456',
};

const validationRules = {
  username: 'required|type|min:3|max:20',
  email: 'required|email',
  password: 'required|type|min:6',
};

validate(validationData, validationRules);

Validators

The library provides the following built-in validators:

  • required: Checks if a value is present and not empty.
  • type: Validates the type of the value (e.g., string, number, array).
  • email: Validates the value as an email address.
  • min: Validates the minimum length for strings or minimum value for numbers.
  • max: Validates the maximum length for strings or maximum value for numbers.

Examples

You can find more examples and use cases in the examples directory.

Contributing

Contributions are welcome! See the Contributing Guidelines for more details.

License

This project is licensed under the MIT License.

0.1.1

7 months ago

0.1.0

7 months ago