(value: unknown, facts: Facts)
| 213 | const record = /^Record<string, (.+)>$/ |
| 214 | |
| 215 | const fits = (value: unknown, facts: Facts): boolean => { |
| 216 | // without exactOptionalPropertyTypes a default replaces undefined, so can't be it |
| 217 | if (value === undefined) return false |
| 218 | if (facts.values) return facts.values.includes(value) |
| 219 | if (typeof value === "string") { |
| 220 | return ( |
| 221 | facts.base === "string" && |
| 222 | value.length >= (facts.min ?? 0) && |
| 223 | value.length <= (facts.max ?? Infinity) |
| 224 | ) |
| 225 | } |
| 226 | return ( |
| 227 | typeof value === "number" && |
| 228 | Number.isFinite(value) && |
| 229 | (facts.base === "number" || |
| 230 | (facts.base === "integer" && Number.isInteger(value))) && |
| 231 | (facts.min === undefined || |
| 232 | (facts.minExclusive ? value > facts.min : value >= facts.min)) && |
| 233 | (facts.max === undefined || |
| 234 | (facts.maxExclusive ? value < facts.max : value <= facts.max)) |
| 235 | ) |
| 236 | } |
| 237 | |
| 238 | const holdsNarrow = 1 |
| 239 | const holdsUnit = 2 |
no outgoing calls
no test coverage detected