# test-react-pwr-library

> "A simple react component that accepts a list of password requirements and updates each as they are fulfilled"

Latest version **1.0.7** (published 2021-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install test-react-pwr-library
pnpm add test-react-pwr-library
yarn add test-react-pwr-library
bun add test-react-pwr-library
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2021-07-19 |
| First published | 2021-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Shakib Ahmed |
| Maintainers | neo1729 |

## Links

- npm: https://www.npmjs.com/package/test-react-pwr-library
- npm.io page: https://npm.io/package/test-react-pwr-library

## Recent versions

- 1.0.7 (latest) — 2021-07-19
- 1.0.6 — 2021-07-19
- 1.0.5 — 2021-07-19
- 1.0.4 — 2021-07-15
- 1.0.3 — 2021-07-15
- 1.0.2 — 2021-07-09
- 1.0.1 — 2021-07-09
- 1.0.0 — 2021-07-09

## README

A simple React component that accepts a list of password requirements and updates them as they are fulfilled.

![test-react-pwr-library](https://user-images.githubusercontent.com/39847281/125712236-eaaf8fc0-411b-4b13-9c36-87073011a186.gif)

### Usage

1. Install the package:

```
   npm i test-react-pwr-library
```

2. Import the Requirements component and use it in the app, it takes 3 props:

   a. value: The password value

   b. requirements: The list of requirements

   c. onValidChange: The functions to call when the password value changes

Example implementation:

```
    import React, { useState } from 'react';
    import logo from './logo.svg';
    import './App.css';
    import { Requirements } from 'test-react-pwr-library';

    function App() {
    const [valid, setValid] = useState(false);
    const [password, setPassword] = useState('');
    const [username, setUsername] = useState('');

    const passwordRequirements = [
        {
        text: 'Must be at least 8 characters',
        validator: (val) => val.length >= 8,
        },
        {
        text: 'Must contain at least one number',
        validator: (val) => /\d/g.test(val),
        },
        {
        text: 'Must contain at least one lower-case letter',
        validator: (val) => /[a-z]/g.test(val),
        },
        {
        text: 'Must contain at least one upper-case letter',
        validator: (val) => /[A-Z]/g.test(val),
        },
    ];

    return (
        <div className='form'>
        <h1>Signup</h1>

        <Requirements
            value={password}
            requirements={passwordRequirements}
            onValidChange={(isValid) => setValid(isValid)}
        />

        <input
            placeholder='Username'
            value={username}
            onChange={(e) => setUsername(e.target.value)}
        />
        <input
            placeholder='Password'
            type='password'
            value={password}
            onChange={(e) => setPassword(e.target.value)}
        />

        <button disabled={!valid || !username}>Sign Up</button>
        </div>
    );
    }

    export default App;
```

### Acknowledgement

Developed this by watching tutorial at PortEXE's YouTube channel: https://www.youtube.com/c/PortEXE

---
_Source: https://npm.io/package/test-react-pwr-library · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
