0.1.0 • Published 7 years ago

adonis-geojson-validator v0.1.0

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

Adonis GeoJSON Validator

Easy GeoJSON validation for adonis framework.

Installation

  1. Add package:
$ npm i adonis-geojson-validator --save

or

$ yarn add adonis-geojson-validator
  1. Register providers inside the your start/app.js file.
const providers = [
  ...
  'adonis-geojson-validator/providers/GeoJsonValidatorProvider',
  ...
]

Validation example

const rules = {
  geojson: 'geojson:feature_collection'
}

const data = {
  geojson: {
    type: 'FeatureCollection',
    features: [
      {
        type: 'Feature',
        geometry: {
          type: 'Point',
          coordinates: [102.0, 0.5]
        },
        properties: {
          prop0: 'value0'
        }
      },
      {
        type: 'Feature',
        geometry: {
          type: 'LineString',
          coordinates: [
            [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
          ]
        },
        properties: {
          prop0: 'value0',
          prop1: 0.0
        }
      }
    ]
  }
}

await Validator.validate(data, rules)

Supported types:

Credits

Support

Having trouble? Open an issue!

License

The MIT License (MIT). Please see License File for more information.

0.1.0

7 years ago

0.0.1

7 years ago