1.0.1 • Published 5 years ago

jean-geo-coordinate-validator v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Description

Validates geographical coordinates (latitude, longitude)

Support

Supports both CommonJS and AMD eco system. If there is no loader, GeoCoordinateValidator is registered as a browser variable.

Code Example

  • Use it as browser variable
var obj = new GeoCoordinateValidator();
  • Use it with require.js
require(["path/to/GeoCoordinateValidator"], function(GeoCoordinateValidator){
    // valid
    var valid = { longitude: 95, latitude: 35 },
        invalid = { longitude: 185, latitude: 95};

    GeoCoordinateValidator.isCoordinateValid(valid);   // true
    GeoCoordinateValidator.isCoordinateValid(invalid); // false
});
  • Use it with node.js
var GeoCoordinateValidator = require("jean-geo-coordinate-validator");

Installation

npm install jean-geo-coordinate-validator --save --legacy-bundling

API Reference

GeoCoordinateValidator.isCoordinateValid(coordinate)

Validates a geographical coordinate

Parameters

  • coordinate: Object - coordinate object
  • coordinate.latitude: Number - longitude value
  • coordinate.longitude: Number - latitude value

Returns

  • Boolean - True if coordinate is valid, false otherwise

GeoCoordinateValidator.isLongitudeValid(longitude)

Validates longitude value

Parameters

  • longitude: Number - longitude value

Returns

  • Boolean - True if longitude is valid, false otherwise

GeoCoordinateValidator.isLatitudeValid(latitude)

Validates latitude value

Parameters

  • latitude: Number - latitude value

Returns

  • Boolean - True if latitude is valid, false otherwise

Tests

  • Open spec/spec-runner.html in browser to see the test cases.

License

MIT

1.0.1

5 years ago

1.0.0

5 years ago