(not: { readonly [x: string]: unknown })
| 169 | |
| 170 | /** Rewrites a negated character class as an anchored positive pattern. */ |
| 171 | const negatedClassPattern = (not: { readonly [x: string]: unknown }): string | undefined => { |
| 172 | if (Object.keys(not).length !== 1 || !Predicate.isString(not.pattern)) return undefined |
| 173 | const match = /^\[\^((?:[^\\[\]]|\\.)+)\]$/.exec(not.pattern) |
| 174 | return match === null ? undefined : `^[${match[1]}]*$` |
| 175 | } |
| 176 | |
| 177 | /** Rewrites supported negations as positive constraints; leaves other forms for the importer to reject. */ |
| 178 | const rewriteNot = (js: JsonSchema.JsonSchema): JsonSchema.JsonSchema => { |
no test coverage detected