(regExp: globalThis.RegExp, annotations?: Schema.Annotations.Filter)
| 3298 | * @since 4.0.0 |
| 3299 | */ |
| 3300 | export function isPattern(regExp: globalThis.RegExp, annotations?: Schema.Annotations.Filter) { |
| 3301 | const source = regExp.source |
| 3302 | const pattern = new globalThis.RegExp(source, regExp.flags) |
| 3303 | return makeFilter( |
| 3304 | (s: string) => { |
| 3305 | pattern.lastIndex = 0 |
| 3306 | return pattern.test(s) |
| 3307 | }, |
| 3308 | { |
| 3309 | expected: `a string matching the RegExp ${source}`, |
| 3310 | representation: { |
| 3311 | id: "effect/schema/isPattern", |
| 3312 | payload: { source, flags: regExp.flags } |
| 3313 | }, |
| 3314 | toJsonSchema: () => ({ pattern: source }), |
| 3315 | arbitrary: { |
| 3316 | constraint: { |
| 3317 | patterns: [regExp.source] |
| 3318 | } |
| 3319 | }, |
| 3320 | ...annotations |
| 3321 | } |
| 3322 | ) |
| 3323 | } |
| 3324 | |
| 3325 | function modifyOwnPropertyDescriptors<A extends AST>( |
| 3326 | ast: A, |
no test coverage detected