* Validate new property value before setting it. * * @param {*} value - New value * @throws Error if the property is readonly or is invalid
(value: any)
| 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. |