Skip to content

Conversation

@knoan
Copy link

@knoan knoan commented Dec 12, 2025

Summary

Adds support for regex flags in tags.Pattern, addressing #1699.

Type tag syntax

// Case-insensitive matching
type CaseInsensitive = string & typia.tags.Pattern<"^hello$", "i">;

// Unicode property escapes (requires 'u' flag)
type Identifier = string & typia.tags.Pattern<"^[\\p{ID_Start}_$][\\p{ID_Continue}_$]*$", "u">;

Comment tag syntax

/** @pattern /^hello$/i */
caseInsensitive: string;

Changes

  • Extended Pattern<Value, Flags> type with optional second parameter for flags
  • Updated MetadataCommentTagFactory to parse regex literal syntax /pattern/flags
  • Updated RandomProgrammer to pass flags to RegExp constructor
  • Added x-pattern-flags schema extension for JSON schema output
  • Added test structures for both type tag and comment tag syntax

Closes #1699

@knoan knoan closed this Dec 12, 2025
@knoan knoan reopened this Dec 12, 2025
@knoan knoan force-pushed the feature/pattern-flags branch from ee0072c to 85ec09d Compare December 12, 2025 15:01
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 12, 2025

Open in StackBlitz

npm i https://pkg.pr.new/typia@1701

commit: 85ec09d

@samchon
Copy link
Owner

samchon commented Dec 12, 2025

Have to be careful due to JSON schema reason. I will consider the way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Support regex flags in tags.Pattern (for Unicode property escapes)

2 participants