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-ip-address

v1.1.13

Published

AngularJS directive that will validate an IP address and impose relevant character and structure limits

Downloads

520

Readme

Downloads

ng-ip-address

Description

An attribute directive that will limit an input to appropriate IP address characters and structure, as well as validate the value.

Currently only supports IPv4 Addresses

View a live demo on Plnkr, CodePen, or jsFiddle.

Versions

Vanilla does not include the additional configuration options, is a smaller file and has lower compatibility requirements.

Compatibility

AngularJS

| Vanilla | Full | | --- | --- | | 1.0+ | 1.4+ |

AngularJS compatibility of full ngIpAddress is limited by $watchCollection() method.

Browsers

| Chrome | Firefox | Internet Explorer | Opera | Safari | | --- | --- | --- | --- | --- | | 1.0+ | 1.0+ | 9+ | 8.0+ | Yes |

Browser compatibility is limited by setSelectionRange() method.

Install

NPM version

npm install ng-ip-address

Bower version

bower install ng-ip-address --save

Usage

Include ngIpAddress.min.js or ngIpAddress.vanilla.min.js in your build or directly with a <script> tag and require the module in your module definition:

angular  
    .module('App', [  
        'ng-ip-address',
        ... // other dependencies  
    ]);
<input type="text" ng-model="model" ng-ip-address />

Entries breaking one of the validation rules will cause the input to become invalid and gain the ng-invalid-ip-address class. Valid entries will have ng-valid-ip-address class.

You can also hook to $error with "ipAddress", ex: form.ipAddressInput.$error.ipAddress.

Additional Options

Vanilla version does not include additional options.

Port options are accessed through ng-ip-config property.

<input ng-model="model" ng-ip-address ng-ip-config="ipConfigObject" />
$scope.ipConfigObject = {
    allowPort: true
};

or

$scope.ipConfigObject = {
    requirePort: true
};

Options default to false and setting requirePort to true overrides allowPort.

Features

Limits User Input

  • Four segments with optional port (ex: 172.16.254.1:24213)
  • Each segment limited to 3 numbers
  • Leading zeroes are removed (ex: 2.02 will be turned into 2.2)
  • Duplicate periods are removed
  • Characters limited to numbers and period
with allowPort set to true
  • Limited to one colon in the fourth IP segment
  • Port is limited to 5 numbers

Validates User Input

  • Each segment must be between 0 and 255
  • Must be 4 segments
with allowPort set to true
  • If port exists, it must be between 1 and 65535
with requirePort set to true
  • Port must be present