How to use password-validator - 2 common examples

To help you get started, we’ve selected a few password-validator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pearce89 / graphql-auth / server / src / app / models / User / Validation.js View on Github external
import passwordValidator from 'password-validator'
import validator from 'validator'
import _ from 'lodash'

import {
  User
} from '~/src/app/models/User/Model'

const passwordSchema = new passwordValidator()

passwordSchema
  .is().min(8)
  .is().max(64)
  .has().not().spaces()
  .has().uppercase()
  .has().lowercase()
// .has().digits()


const passwordErrorsMessages = {
  min: 'Password should be at least 8 charachters long',
  max: 'Password should be be a maximum of 64 characters long',
  uppercase: 'Password should have uppercase characters',
  lowercase: 'Password should have lowercase characters',
  digits: 'Password should contain digits',

password-validator

Validates password according to flexible and intuitive specifications

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular password-validator functions