Resource with id 7 from Device object (3) has the following specifications:
/**
* Power Source Voltage
*
* Present voltage for each Available Power Sources Resource Instance. The unit
* used for this resource is in mV.
*
* ID: 7
* MultipleInstances: true
* Mandatory: false
*/
The Document Schema generated by the library defines it as an array:
"7": {
"type": "array",
"minItems": 1,
"items": { "type": "integer" },
"title": "Power Source Voltage",
"description": "Present voltage for each Available Power Sources Resource Instance. The unit used for this resource is in mV."
},
But in order with its type definition, it is a number:
type PowerSourceVoltage_7 = number
When the expected would be an array of numbers
type PowerSourceVoltage_7 = number[]
because it is a multiple instance.
The schema defines it as an array, so it is not a problem when checking the veracity of it.
const input = {
[Device_3_urn]: {
'0': 'Nordic Semiconductor ASA',
'1': 'Thingy:91',
'2': '351358815340515',
'3': '22.8.1+0',
'7': [80],
'11': [0],
'13': 1675874731,
'16': 'UQ',
'19': '3.2.1',
}
}
const maybeValidLwM2M = validate(input)
if ('errors' in maybeValidLwM2M)
return { error: new Error(JSON.stringify(maybeValidLwM2M.errors)) }
return { result: true } // this returns here
But it is an issue when using the type definition
const device: Device_3 = {
'0': 'Nordic Semiconductor ASA',
'1': 'Thingy:91',
'2': '351358815340515',
'3': '22.8.1+0',
'7': [2754], // Type 'number[]' is not assignable to type 'number'.
'11': [0], // Type 'number[]' is not assignable to type 'number'
'13': 1675874731,
'16': 'UQ',
'19': '3.2.1',
}