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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-password-validator

v3.0.0

Published

The password validator is a pop-up window that appears when you start typing in input box. Here you can configure the password acceptance criteria, once your enter characters fullfil the requirement you will get a success message.

Downloads

482

Readme

Password validator for Angular

npm GitHub Contributors GitHub language count npm bundle size GitHub repo size npm NPM GitHub last commit contributions welcome

The password validator is a pop-up window that appears when you start typing in input box. Here you can configure the password acceptance criteria, once your enter characters fullfil the requirement you will get a success message.

Help to make Password Validator better by answering a few questions.

Demo

https://jaganbishoyi.github.io/ngx-password-validator/

Installation

Install the npm package.

npm i ng-password-validator

Import in NgModule:

import { NgPasswordValidatorModule } from 'ng-password-validator';

@NgModule({
    imports: [ NgPasswordValidatorModule ]
})

Usage

Options can be set in the directive tag, so they have the highest priority.

<input type="text" id="password" name="password" placeholder="Password.."
    NgPasswordValidator>

You may pass as an object:

<input type="text" id="password" name="password" placeholder="Password.."
    [NgPasswordValidator]="options">

Password type as 'range':

options = {
    'placement': 'top',
    'rules': {
        'password': {
            'type': "range",
            'min': 6,
            'max': 10,
            // No need to pass length
        }
    },
    'shadow': false,
    'offset': 15,
}

Password type as 'number':

options = {
    'placement': 'top',
    'rules': {
        'password': {
            'type': "number",
            'length': 8,
            // No need to pass min and max
        }
    },
    'shadow': false,
    'offset': 15,
}

Template( Default value is popup ):

<input type="text" id="password" name="password" placeholder="Password.."
    [NgPasswordValidator]="options">

Template as 'inline':

options = {
    'template': 'inline',
    'theme': 'pro'
}

Template as 'popup':

options = {
    'template': 'popup',
    'theme': 'pro'
}

Theming( Default value is pro ):

<input type="text" id="password" name="password" placeholder="Password.."
    [NgPasswordValidator]="options">

Theme as 'basic':

options = {
    'placement': 'top',
    'theme': 'basic'
}

Theme as 'pro':

options = {
    'placement': 'top',
    'theme': 'pro'
}

You can also change Popup header and success message:

<input type="text" id="password" name="password" placeholder="Password.."
    [NgPasswordValidator]="options">
options = {
    'heading': 'Password Requirement',
    'successMessage': 'Wow! Password is Strong.'
}

After closing the popup window, you will get one output for password validity (true/false):

<input type="text" id="password" name="password" placeholder="Password.."
    NgPasswordValidator (valid)="isValid($event)">
isValid(event: boolean) {
    this.isPasswordValid = event;
}

Custom class configuration

In Component HTML file

<input type="text" id="password" name="password" placeholder="Password.."
    [NgPasswordValidator]="options">

In Component TS file

options = {
    'custom-class': 'custom-class',
}

In Component SCSS file

::ng-deep {
    .custom-class {
        .popup-window {
            .heading {
                color: red !important;
                font-family: cursive;
            }
        }
    }
}

Set default values

In app.module.ts export the default options like below:

import { NgPasswordValidatorModule, NgPasswordValidatorOptions } from "ng-password-validator";

export const MyDefaultOptions: NgPasswordValidatorOptions = {
    placement: "right",
    rules: {
        'password': {
            'type': "range",
            'min': 6,
            'max': 10,
        },
        "include-symbol": true,
        "include-number": false,
        "include-lowercase-characters": true,
        "include-uppercase-characters": false,
    }
};

And pass your parameters when importing the module:

@NgModule({
    imports: [
      NgPasswordValidatorModule.forRoot(MyDefaultOptions as NgPasswordValidatorOptions)
    ]
})

Properties

| name | type | default | description | | ------------------ | -------------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------- | | placement | "top", "bottom", "left", "right" | "bottom" | The position of the popup window. | | template | "inline", "popup" | "popup" | Password template | | z-index | number | 0 | Z-index of the popup window. | | trigger | "focus" | | Specifies how the popup window is triggered. | | custom-class | string | | Classes to be passed to the popup window. | | heading | string | Password Policy | Heading of popup window. | | successMessage | string | Awesome! Password requirement fulfilled. | Success message after requirements fulfilled. | | animation-duration | number | 300 | The duration controls how long the animation takes to run from start to finish. | | theme | "basic" | "basic" | Theme of popup window background and text. | | shadow | boolean | true | Shadow of the popup window. | | offset | number | 8 | Offset the popup window relative to the item. | | width | number | undefined | Width of the popup window. | | max-width | number | 390 | Maximum width of the popup window. | | pointerEvents | "auto", "none" | "none" | Defines whether or not an element reacts to pointer events. | | position | {top: number, left: number} | undefined | The popup window coordinates relative to the browser window. |

Events

When you call events, the delays that are specified in the options in the directive are taken into account.

| Event | Description | | ----------------------------------- | ------------------------------------------------------------------------------ | | {type: "show", position: DOMRect} | The event is called before the popup window appears. | | {type: "shown", position: DOMRect} | The event is called after the animation of the appearance of the popup window. | | {type: "hide", position: DOMRect} | The event is called before the popup window is hidden. | | {type: "hidden", position: DOMRect} | The event is called after the animation of the popup window is hidden. |

For any questions, suggestions, or feature requests

Please file an issue!

License

License under the MIT License (MIT)

Copyright (c) 2020-2022 Jagan Mohan Bishoyi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.