(value: unknown)
| 1148 | } |
| 1149 | |
| 1150 | function isModelSelection(value: unknown): value is ModelSelection { |
| 1151 | if (!hasStringProperty(value, "id")) { |
| 1152 | return false |
| 1153 | } |
| 1154 | |
| 1155 | if (!("params" in value)) { |
| 1156 | return true |
| 1157 | } |
| 1158 | |
| 1159 | const params = value.params |
| 1160 | return ( |
| 1161 | params === undefined || |
| 1162 | (Array.isArray(params) && |
| 1163 | params.every((param) => hasStringProperty(param, "id") && hasStringProperty(param, "value"))) |
| 1164 | ) |
| 1165 | } |
| 1166 | |
| 1167 | function hasStringProperty<K extends string>(value: unknown, key: K): value is Record<K, string> { |
| 1168 | if (typeof value !== "object" || value === null || !(key in value)) { |
no test coverage detected