validate.io-ip-address
v1.0.0
Published
Validates if a value is an IP address.
Downloads
5
Maintainers
Readme
IP Address
Validates if a value is an IP address.
Installation
$ npm install validate.io-ip-address
For use in the browser, use browserify.
Usage
To use the module,
var validate = require( 'validate.io-ip-address' );
console.log( validate( '192.168.1.172' ) );
// Returns true
console.log( validate( '10.10.248.244' ) );
// Returns true
console.log( validate( '255.168.92.2' ) );
// Returns true
console.log( validate( '256.168.92.2') );
// Returns false
console.log( validate( '192.168.1.172.1') );
// Returns false
This method validates that the value
to be validated is a string
. For any other value type, the method returns false
.
Examples
To run the example code from the top-level application directory,
$ node ./examples/index.js
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ open reports/coverage/lcov-report/index.html
License
Copyright
Copyright © 2014. Athan Reines.