MCPcopy Create free account
hub / github.com/Effect-TS/effect / isPattern

Function isPattern

packages/effect/src/SchemaAST.ts:3300–3323  ·  view source on GitHub ↗
(regExp: globalThis.RegExp, annotations?: Schema.Annotations.Filter)

Source from the content-addressed store, hash-verified

3298 * @since 4.0.0
3299 */
3300export 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
3325function modifyOwnPropertyDescriptors<A extends AST>(
3326 ast: A,

Callers 3

isStringFiniteFunction · 0.70
isStringBigIntFunction · 0.70
isStringSymbolFunction · 0.70

Calls 1

makeFilterFunction · 0.85

Tested by

no test coverage detected