Gathering detailed insights and metrics for joi-piece-validator
Gathering detailed insights and metrics for joi-piece-validator
Gathering detailed insights and metrics for joi-piece-validator
Gathering detailed insights and metrics for joi-piece-validator
npm install joi-piece-validator
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
38 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Dec 06, 2020
Latest Version
2.2.5
Package Id
joi-piece-validator@2.2.5
Unpacked Size
7.81 kB
Size
1.86 kB
File Count
5
NPM Version
6.13.4
Node Version
12.16.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1npm install --save joi-piece-validator
1import validateJoiPieces from 'joi-piece-validator'; // ES6 2var validateJoiPieces = require('joi-piece-validator'); // ES5 with npm
joi
use same joi version
1const Joi = require("joi") 2const { validateJoiPieces } = require('joi-piece-validator') 3 4//your schema 5const joiSchema = { 6 email: Joi.string() 7 .min(5) 8 .max(50) 9 .required() 10 .email() 11 .trim(), 12 password: Joi.string() 13 .min(5) 14 .max(50) 15 .required(), 16 first_name: Joi.string() 17 .min(2) 18 .max(50) 19 .required() 20 .label('first name') 21 .trim(), 22 last_name: Joi.string() 23 .min(2) 24 .max(50) 25 .required() 26 .label('last name') 27 .trim() 28} 29 30//Only email and password to validate 31const email = 'test@gmail.com' 32const password = '1' 33const pieces = { email, password } 34 35//Pass the joi schema and the piece(s) to validate. 36const { error } = validateJoiPieces(joiSchema, pieces) 37console.log(error)
1const Joi = require("joi") 2const { validateParams } = require('joi-piece-validator') 3 4const joiSchema = { 5 keyword: Joi.string() 6 .max(50) 7 .required(), 8 place_type: Joi.string() 9 .max(50) 10 .required() 11} 12 13//Example of requesting url: http://localhost:3000/api/places/tokyo/region 14//This will validate values of params (keyword and place_type) 15route.get('/:keyword/:place_type', validateParams(joiSchema), async(req, res, next) => { 16 ... await 17}) 18 19//will return the validation error inside response
1const Joi = require("joi") 2const { validateQuery } = require('joi-piece-validator') 3 4const joiSchema = { 5 keyword: Joi.string() 6 .max(50) 7 .required(), 8 place_type: Joi.string() 9 .max(50) 10 .required() 11} 12 13//Example of requesting url: http://localhost:3000/api/places?keyword=tokyo&place_type=region 14//This will validate values of query (keyword and place_type) 15route.get('/', validateQuery(joiSchema), async(req, res, next) => { 16 ... await 17}) 18 19//will return the validation error inside response
1const Joi = require("joi") 2const { validateBody } = require('joi-piece-validator') 3 4const joiSchema = { 5 keyword: Joi.string() 6 .max(50) 7 .required(), 8 place_type: Joi.string() 9 .max(50) 10 .required() 11} 12 13//validateBody(joiSchema, selectively=false) 14//selectively=false is the default value 15//will validate all items in req.body 16route.get('/', validateBody(joiSchema), async(req, res, next) => { 17 ... await 18}) 19 20//validateBody(joiSchema, selectively=true) 21//will only use schema items based on the items from req.body 22//validate only req.body items that found inside the schema 23route.get('/', validateBody(joiSchema, true), async(req, res, next) => { 24 ... await 25}) 26 27//will return the validation error inside response
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
1 existing vulnerabilities detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More