(
regExp: globalThis.RegExp,
annotations?: Annotations.Filter
): SchemaAST.Filter<string>Validates that a string matches the specified regular expression pattern.
Details
JSON Schema:
This check corresponds to the pattern constraint in JSON Schema.
Arbitrary:
When generating test data with fast-check, this applies a patterns
constraint to ensure generated strings match the specified RegExp pattern.
export const const isPattern: (
regExp: globalThis.RegExp,
annotations?: Annotations.Filter
) => SchemaAST.Filter<string>
Validates that a string matches the specified regular expression pattern.
Details
JSON Schema:
This check corresponds to the pattern constraint in JSON Schema.
Arbitrary:
When generating test data with fast-check, this applies a patterns
constraint to ensure generated strings match the specified RegExp pattern.
isPattern: (regExp: globalThis.RegExpregExp: module globalThisglobalThis.RegExp, annotations: Annotations.Filter | undefinedannotations?: Annotations.interface Annotations.FilterAnnotations for filter schema nodes (created via Schema.filter). Extends
Augment
with an optional error message, identifier, and metadata.
Filters are intentionally non-parametric to keep them covariant.
Filter) => import SchemaASTSchemaAST.class Filter<in E>class Filter {
_tag: 'Filter';
run: (input: E, self: AST, options: ParseOptions) => SchemaIssue.Issue | undefined;
annotations: Schema.Annotations.Filter | undefined;
aborted: boolean;
annotate: (annotations: Schema.Annotations.Filter) => Filter<E>;
abort: () => Filter<E>;
and: (other: Check<E>, annotations?: Schema.Annotations.Filter) => FilterGroup<E>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Represents a single validation check attached to an AST node.
Details
run — the validation function. Returns undefined on success, or an
Issue on failure.
annotations — optional filter-level metadata (expected message, meta
tags, arbitrary constraint hints).
aborted — when true, parsing stops immediately after this filter
fails (no further checks run).
Use .annotate() to add metadata and .abort() to mark as aborting.
Combine with another check via .and() to form a
FilterGroup
.
Filter<string> =
import SchemaASTSchemaAST.function isPattern(
regExp: globalThis.RegExp,
annotations?: Annotations.Filter
): SchemaAST.Filter<string>
Creates a
Filter
that validates strings by running RegExp.test.
When to use
Use when string validation should be represented as a schema Filter backed
by a regular expression.
Details
The filter can be used with Schema.filter or attached directly to a
String AST node through checks. The regular expression source is stored in
annotations for serialization and arbitrary generation.
Gotchas
Use a non-global, non-sticky regular expression, or reset lastIndex
yourself, because RegExp.test is stateful for expressions with the g or
y flag.
Example (Validating an email pattern)
import { SchemaAST } from "effect"
const emailFilter = SchemaAST.isPattern(/^[^@]+@[^@]+$/)
isPattern