Socket
Socket
Sign inDemoInstall

validate-fields-body

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    validate-fields-body

Validate-Fields-Body is a Javascript library for dealing with validation.


Version published
Weekly downloads
1
decreased by-90.91%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Validate-Fields-Body

Validate-Fields-Body is a Javascript library for dealing with validation.

Installation

npm i validate-fields-body

Usage

const { useValidate } = require("validate-fields-body");

const fieldsValidate = ["username", "email", "password"];
const [isValid, logs, result] = useValidate(fieldsValidate, req.body);

// isValid: return Boolean
// logs: return Array
// result: # if passed result will return your object fields

Add "!" In Front Of Field Key For Required Value

const { useValidate } = require("validate-fields-body");

const fieldsValidate = ["!username", "!password", "email"];
const [isValid, logs, result] = useValidate(fieldsValidate, req.body);

// isValid: return Boolean
// logs: return Array
// result: # if passed result will return your object fields

Add ":[TYPES]" After Field Key For Validate Type

Types : number, string, boolean, object, undefined
const { useValidate } = require("validate-fields-body");

const fieldsValidate = ["!username:string", "password:string", "age:number"];
const [isValid, logs, result] = useValidate(fieldsValidate, req.body);

// isValid: return Boolean
// logs: return Array
// result: # if passed result will return your object fields

Contributing

Thanks you :).

Donation

Buy me a coffee

Author by: Nero Sengtianthr.

License

MIT

Keywords

FAQs

Last updated on 13 Feb 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc