Comments (2)
I suggest to change index.js line 496 to the following:
Feature.schemaName = 'Feature'
function validateFeature(feature) {
if (!feature.type) {
throw new mongoose.Error('Feature must have a type')
}
// type must be Feature
if (feature.type !== 'Feature') {
throw new mongoose.Error(feature.type + ' is not a valid GeoJSON type')
}
if (!feature.geometry) {
throw new mongoose.Error('Feature must have a geometry')
}
// check for crs
if (feature.crs) {
crs = feature.crs
validateCrs(crs)
}
validateGeometry(feature.geometry)
validateFeatureProperties(feature.properties)
}
function validateFeatureProperties(properties) {
if (properties === null) return
if (!properties) {
throw new mongoose.Error('Feature must have a "properties" member')
}
if (typeof properties !== 'object') {
throw new mongoose.Error('Feature properties must be a JSON object or a null value.')
}
}
from mongoose-geojson-schema.
Hi @OlivierMartineau. Great suggestion. Feel free to make a PR for this.
from mongoose-geojson-schema.
Related Issues (20)
- CastError surfacing still an issue HOT 3
- Can't use $geoIntersects HOT 1
- Correct way to 2dsphere index when using these schema
- Can't query using `$nearSphere` because of model validation of query object HOT 2
- Add "schemaName" to each of the SchemaTypes HOT 1
- Typeerror: GeoJSON is not a constructor HOT 1
- nullable field HOT 6
- The cast function doesn't take JSON into consideration HOT 2
- Cannot create type point with point array HOT 2
- Typescript definition HOT 4
- Does not work with mongoose 5.x HOT 1
- Failing to validate a GeometryCollection inside a Feature HOT 4
- add pure export
- Passing NaN as point coordinates should fail HOT 6
- Conflicts on typescript compile HOT 2
- Remove `@types/mongoose` dependency HOT 1
- Open to PRs? HOT 30
- specific errors are not available when validation fails HOT 1
- GeoJSON type HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose-geojson-schema.