sure-guard
v1.0.5
Published
Node library for data validation
Downloads
43
Maintainers
Readme
SureGuard.js
Description
Node library for data validation
Installation
To install SureGuard.js, use the following npm command:
npm install sure-guard
Methods
NumberValidator
| Method | Description | Parameters | Return |
|--------------------|--------------------------------------------------|------------------------------|---------|
| isNumber
| Checks if the value is of type number. | None | this
|
| isMinValue
| Checks if the value is greater than or equal to a minimum.| minValue: number
| this
|
| isMaxValue
| Checks if the value is less than or equal to a maximum.| maxValue: number
| this
|
| isPositive
| Checks if the value is positive. | None | this
|
| isNegative
| Checks if the value is negative. | None | this
|
| isInteger
| Checks if the value is an integer number. | None | this
|
| getResult
| Returns the result of the validation. | None | boolean
|
StringValidator
| Method | Description | Parameters | Return |
|--------------------|--------------------------------------------------|------------------------------|---------|
| isString
| Checks if the value is of type string. | None | this
|
| isMaxSize
| Checks if the string size is less than or equal to a maximum.| maxSize: number
| this
|
| isMinSize
| Checks if the string size is greater than or equal to a minimum.| minSize: number
| this
|
| isEmail
| Checks if the string is a valid email address. | None | this
|
| isAlphanumeric
| Checks if the string contains only alphanumeric characters.| None | this
|
| getResult
| Returns the result of the validation. | None | boolean
|
Usage Example
const { validator } = require('sure-guard');
const result1 = validator('hello').string().isEmail().getResult();
// result1 === false
const result2 = validator(123).number().isPositive().getResult();
// result2 === true
Contributing
If you wish to contribute to SureGuard.js, please follow these steps:
- Fork the project.
- Create a branch for your contribution (
git checkout -b feature/new-feature
). - Make your desired changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to your branch (
git push origin feature/new-feature
). - Open a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.