menu
up-caret
down-caret

Node.js

A Spectrum community for Node.js ✨🐢🚀✨

# help

Ask questions about Node.js

Trending conversations
OAuth 2 client credentials token received in postman but not in server
@mariusz-sygnowski · 12h
I'm unable to install gulp on my windows
@ug · 35d
Charge, an opinionated, zero-config static site generator
@brandonweiss · 8h
auth2 tokken works in postman but not on server - node js
@mariusz-sygnowski · 2d
Function evaluates to undefined when executed in production cloud instance only
@federico-dev · 5d

Node JS Password Complexity check?

Node.js/help · December 3, 2018 at 1:27am

Node JS Password Complexity check?

December 3, 2018 at 1:27am

Hi Guys,

I'm new in NodeJs. Currently I'm validating my schema like this:

const userValidator = (userObj) => {

const schema = {

name: Joi.string().min(5).max(50).required(),

email: Joi.string().min(5).max(255).required().email(),

password: Joi.string().min(5).max(255).required()

}

return Joi.validate(userObj, schema);

}

-----------------------------------------

Now I Want to use Joi Password Complexity library(https://www.npmjs.com/package/joi-password-complexity). Can you help me how I can use it within my schema. I'm trying from last week.

How I can use its function within schema please guide me.


December 3, 2018 at 2:09am

As per 'joi-password-complexity' README, joi.validate() accepts 2 arguments: 1) string, 2) instance of "joi-password-complexity" package. So, I believe, in your case, you'll have to create 3 instances for name, email, and password. And validate them one by one.

* My answer is based on the theory

  • reply
  • like

December 3, 2018 at 12:16pm

As per 'joi-password-complexity' README, joi.validate() accepts 2 arguments: 1) string, 2) instance of "joi-password-complexity" package. So, I believe, in your case, you'll have to create 3 instances for name, email, and password. And validate them one by one.

* My answer is based on the theory

Hi Amit, yeah. But I need to clarify one thing , I just wanna check password complexity. And what I'll return I'm not sure about that.

  • reply
  • like

December 4, 2018 at 1:05am

If I understand you correctly, you want to validate all three fields for their formats and password for it's format and validity. If my understanding is correct, you can check for password complexity just before returning the result of validate.

like-fill
1
  • reply
  • like

December 10, 2018 at 1:07am

If I understand you correctly, you want to validate all three fields for their formats and password for it's format and validity. If my understanding is correct, you can check for password complexity just before returning the result of validate.

Thank you Amit. I got it.

  • reply
  • like