@bluedot-innovation/models 5.1.29 → 5.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 5.1.30
2
+ - Added DayRange validation
3
+
1
4
  ## 5.1.29
2
5
  - Validated BoundingBox and Polygon's area should be at least 70 square metres
3
6
 
@@ -1,7 +1,7 @@
1
1
  let mongoose = require('mongoose')
2
2
 
3
3
  let schema = {
4
- startDate: {type: Date},
4
+ startDate: {type: Date, validate: validateDateRange},
5
5
  endDate: {type: Date}
6
6
  }
7
7
 
@@ -11,7 +11,7 @@ let DayRangeConditionSchema = new mongoose.Schema(schema, {
11
11
  })
12
12
 
13
13
  DayRangeConditionSchema.add({
14
- type: {type: String, required: true, validate: {isAsync: true, validator: validateDateRange}}
14
+ type: {type: String, required: true, validate: validateDateRange}
15
15
  })
16
16
 
17
17
  function validateDateRange (type, callback) {
@@ -20,7 +20,7 @@ function validateDateRange (type, callback) {
20
20
 
21
21
  if (!startDate && !endDate) return callback(false, `Must have a startDate, endDate, or both.`)
22
22
 
23
- if (!startDate) startDate = new Date(this.startDate)
23
+ if (!startDate) startDate = new Date(startDate)
24
24
 
25
25
  if (!endDate) endDate = new Date(endDate)
26
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.29",
3
+ "version": "5.1.30",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",