npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

password-validator-lib

v1.1.8

Published

A reusable password validator component for React

Readme

🔐 Password Validator Library

A reusable and customizable React component for validating passwords. Designed to be flexible and adaptable to various frontend needs.


📦 Installation

It is possible to install it via git:

git clone https://github.com/Joao-Pacheco/qventus-app-password.git

After cloning the repository, simply run the following command in the project folder to install the dependencies:

npm i

Then run this other command to start the server:

npm run dev

Now simply open the suggested localhost URL in your browser. On the home page, you’ll see a live example of how the password-validator-lib works (as shown in the image above). This example is located in the /src/pages/ExamplePage.tsx file within the project, in case you want to review its implementation.

Or install the library via npm(yes, I uploaded the project to npm, here):

npm install password-validator-lib

🚀 Usage Example

Here’s how to use the PasswordValidator component in your React project:

import { PasswordValidator } from "password-validator-lib";

function App() {
  return (
    <PasswordValidator
      options={["digit", "uppercase", "specialChar", "noConsecutive"]}
      onValidChange={(password, isValid) => {
        console.log("Password:", password, "Is valid?", isValid);
      }}
    />
  );
}

🔧 Configuration Options

The PasswordValidator component is highly configurable. Below are the available props:

1. options (required)

An array of predefined validation rules:

| Key | Description | | --------------- | ---------------------------------------------------------- | | specialChar | Must contain at least one special character (!@#$%^&*) | | digit | Must contain at least one number | | uppercase | Must contain at least one uppercase letter | | noConsecutive | Must not contain consecutive repeated letters (e.g., "aa") |


2. customRules (optional)

Add your own validation rules with custom messages:

customRules={[
  {
    message: "Must contain the word 'secure'",
    validate: (password) => password.includes("secure"),
  },
]}

3. onValidChange (optional)

Callback that receives the current password and whether it’s valid:

onValidChange={(password, isValid) => {
  setIsButtonEnabled(isValid);
}}

4. customStyles (optional)

Customize styles using your own CSS classes:

| Key | Description | | ----------- | ------------------------------- | | container | Wrapper container | | input | Password input field | | label | Input label | | button | Show/hide password button | | list | Validation rules list container | | listItem | Individual validation rule item |

Example of customization:

const customStyles = {
  container: "bg-gray-100 p-4 rounded-lg",
  input: "border border-blue-500",
  label: "text-blue-500",
  button: "text-blue-500 hover:text-blue-700",
  list: "mt-4",
  listItem: "text-sm",
};

5. label (optional)

Set a custom label for the password input:

label = "Create your password";

🧪 Running Tests

This project uses Jest and React Testing Library.

npm test       # Run all tests
npm test --watch  # Run in watch mode

✅ Where can I see the predefined validation rules?

Go to the following folder

/src/utils/validators.ts

📚 Cool features i implemented

  • 🚀 I uploaded it to NPM – Facilitating tests and implementations
  • Predefined Rules – Validate common password formats
  • Custom Rules – Add your own logic
  • 🎨 Custom Styles – Easily match your design system
  • Real-time Validation – Feedback as the user types

🌟 Features that if I had more time I would implement

  • ✅ Ideally, the component and the test page would be separated into different repositories — one for the library itself and another for showcasing usage examples. This separation would make the project structure much cleaner, more organized, and easier to maintain. However, to simplify testing and evaluation for now, I decided to keep both the component and the example page in the same repository
  • 🔒 A visual password security meter
  • 🧪 An automatic secure password generator
  • ⚡ when a custom style is called, override the original by disabling it
  • 🗣️ Internationalization (i18n)
  • ⚙️ Custom error messages
  • ♿ Improved accessibility (WCAG)

🧑‍💻 Author

Made with 💙 for João Pacheco for Qventus' technical challenge