Skip to content

Close #1699: support regex flags in tags.Pattern#1701

Closed
knoan wants to merge 1 commit intosamchon:masterfrom
knoan:feature/pattern-flags
Closed

Close #1699: support regex flags in tags.Pattern#1701
knoan wants to merge 1 commit intosamchon:masterfrom
knoan:feature/pattern-flags

Conversation

@knoan
Copy link
Copy Markdown

@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
Copy Markdown

pkg-pr-new bot commented Dec 12, 2025

Open in StackBlitz

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

commit: 85ec09d

@samchon
Copy link
Copy Markdown
Owner

samchon commented Dec 12, 2025

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

Copy link
Copy Markdown
Owner

@samchon samchon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON schema does not define the flags, so I have to be careful.

I'm changing the typia to be monorepo, so if you still want this feature, can you re-request it to the packages/interface module?

@samchon samchon closed this Mar 6, 2026
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