fully-typed-geopoint

1.0.1 • Public • Published

Fully Typed GeoPoint

A GeoPoint plugin for fully-typed. Validates that a value is an object with required properties for latitude and longitude.

Installation

npm install fully-typed-geopoint

Usage

const Typed = require('fully-typed');
const GeoPoint = require('fully-typed-geopoint');

// register the plugin
Typed.controllers.register(GeoPoint);

// define a schema that uses the plugin
const schema = Typed({
    type: GeoPoint,              // or "geoPoint" as a string
    latitudeRange: [-90, 90],    // this is the default
    longitudeRange: [-180, 180]  // this is the default
});

let error;

// check a value for errors
error = schema.error({ latitude: 21.289373, longitude: -157.917480 });
// error => null

// check a value for errors
error = schema.error(25);
// error => "Expected an object with numeric latitude and longitude values."

// check a value for errors
error = schema.error({ latitude: 1000, longitude: 0 });
// error => "Latitude must be between -90 and 90"

Readme

Keywords

Package Sidebar

Install

npm i fully-typed-geopoint

Weekly Downloads

6

Version

1.0.1

License

ISC

Last publish

Collaborators

  • gi60s