@bluedot-innovation/models 3.0.6-alpha.3 → 3.0.7-alpha.1
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 +3 -0
- package/__tests__/beacon/beacon.rules.json +2 -2
- package/models/Beacon.js +6 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
{
|
|
5
5
|
"property": "beaconType",
|
|
6
6
|
"pairings": [
|
|
7
|
-
{"value": "ios", "requiredFields": ["major", "minor"]},
|
|
7
|
+
{"value": "ios", "requiredFields": ["proximityUUID", "major", "minor"]},
|
|
8
8
|
{"value": "android", "requiredFields": ["macAddress"]},
|
|
9
|
-
{"value": "both", "requiredFields": ["major", "minor", "macAddress"]}
|
|
9
|
+
{"value": "both", "requiredFields": ["proximityUUID", "major", "minor", "macAddress"]}
|
|
10
10
|
]
|
|
11
11
|
}
|
|
12
12
|
]
|
package/models/Beacon.js
CHANGED
|
@@ -54,26 +54,23 @@ function validateMajorMinor (v) {
|
|
|
54
54
|
return v >= 0 && v <= 65535
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function validateBeaconType (v,
|
|
57
|
+
function validateBeaconType (v, callback) {
|
|
58
58
|
'use strict'
|
|
59
59
|
const beaconType = v
|
|
60
|
-
const minor = this
|
|
61
|
-
const major = this.major
|
|
62
|
-
const macAddress = this.macAddress
|
|
63
|
-
const txPower = this.txPower
|
|
60
|
+
const { minor, major, macAddress, proximityUUID } = this;
|
|
64
61
|
|
|
65
62
|
let androidRegex = new RegExp(/(android)/ig)
|
|
66
63
|
let iosRegex = new RegExp(/(ios)/ig)
|
|
67
64
|
let bothRegex = new RegExp(/(both)/ig)
|
|
68
65
|
|
|
69
66
|
if (androidRegex.test(beaconType)) {
|
|
70
|
-
|
|
67
|
+
callback((!!macAddress), "Beacon type 'Android' must have a mac address")
|
|
71
68
|
} else if (iosRegex.test(beaconType)) {
|
|
72
|
-
|
|
69
|
+
callback((!!proximityUUID && !!minor && !!major), "Beacon type 'IOS' must have 'proximityUUID', 'minor' and 'major' values")
|
|
73
70
|
} else if (bothRegex.test(beaconType)) {
|
|
74
|
-
|
|
71
|
+
callback((!!proximityUUID && !!minor && !!major && !!macAddress), "Beacon type 'Both' must have all of 'proximityUUID', 'minor', 'major', and 'mac address' values")
|
|
75
72
|
} else {
|
|
76
|
-
|
|
73
|
+
callback(true)
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
|
package/package.json
CHANGED