| 6743 | * @since 4.0.0 |
| 6744 | */ |
| 6745 | export function isPattern( |
| 6746 | regExp: globalThis.RegExp, |
| 6747 | annotations?: Annotations.Filter |
| 6748 | ): SchemaAST.Filter<string> { |
| 6749 | const source = regExp.source |
| 6750 | const flags = regExp.flags |
| 6751 | const runtimeRegExp = flags === "" |
| 6752 | ? `new RegExp(${format(source)})` |
| 6753 | : `new RegExp(${format(source)}, ${format(flags)})` |
| 6754 | return SchemaAST.isPattern(regExp, { |
| 6755 | toCode: () => ({ runtime: `Schema.isPattern(${runtimeRegExp})` }), |
| 6756 | ...annotations |
| 6757 | }) |
| 6758 | } |
| 6759 | |
| 6760 | const IsPatternPayload = Struct({ |
| 6761 | source: String, |