MCPcopy Index your code
hub / github.com/WebThingsIO/webthing-node / validateValue

Method validateValue

lib/property.ts:68–77  ·  view source on GitHub ↗

* Validate new property value before setting it. * * @param {*} value - New value * @throws Error if the property is readonly or is invalid

(value: any)

Source from the content-addressed store, hash-verified

66 * @throws Error if the property is readonly or is invalid
67 */
68 validateValue(value: any): asserts value is ValueType {
69 if (this.metadata.hasOwnProperty('readOnly') && this.metadata.readOnly) {
70 throw new Error('Read-only property');
71 }
72
73 const valid = this.validate(value);
74 if (!valid) {
75 throw new Error('Invalid property value');
76 }
77 }
78
79 /**
80 * Get the property description.

Callers 1

setValueMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected