Easy GeoJSON validation for adonis framework.
- Add package:
$ npm i adonis-geojson-validator --save
or
$ yarn add adonis-geojson-validator
- Register providers inside the your start/app.js file.
const providers = [
...
'adonis-geojson-validator/providers/GeoJsonValidatorProvider',
...
]
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:
- geometry_object
- position
- point
- multi_point_coords
- multi_point
- line_string_coords
- line_string
- multi_line_string_coords
- multi_line_string
- polygon_coords
- polygon
- multi_polygon_coords
- multi_polygon
- geometry_collection
- feature
- feature_collection
- bbox
Having trouble? Open an issue!
The MIT License (MIT). Please see License File for more information.