(type)
| 172 | } |
| 173 | |
| 174 | function projectRef(type) { |
| 175 | const all = typeList(type) |
| 176 | // A missing type (undefined/empty input, e.g. a malformed array element or map |
| 177 | // value) is not a `null` value — fail closed so checkSchema's unknown guard |
| 178 | // catches it instead of silently producing a valid-looking `null`. |
| 179 | if (all.length === 0) return { primitive: 'unknown' } |
| 180 | const entries = all.filter((e) => !isNullAlt(e)) |
| 181 | const node = |
| 182 | entries.length > 1 |
| 183 | ? entries.every(isLiteral) |
| 184 | ? enumNode(entries) |
| 185 | : unionNode(entries.map(projectEntry)) |
| 186 | : projectEntry(entries[0]) |
| 187 | if (entries.length < all.length) node.nullable = true // a `null` alternative means the value may be null |
| 188 | return node |
| 189 | } |
| 190 | |
| 191 | const BOUND_OPERATORS = { |
| 192 | ge: { side: 'min', exclusive: false }, |
no test coverage detected