Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Users can enter invalid regex patterns in library filter and rename rules, causing runtime errors during application with non-obvious feedback. This adds client-side validation that shows errors immediately as users type.

Changes

Validation Logic

  • Created RegexValidator helper class with IsValidRegex() method
  • Validates patterns by attempting Regex.Match() and catching ArgumentException
  • Applied to both EditLibraryFilterForm and EditLibraryRenameForm components

UI Feedback

  • Added Error and ErrorText attributes to pattern input fields
  • Validation only triggers when PatternType is Regex (not Contains)
  • Error text appears immediately with Immediate="true" binding

Localization

  • Added Error_InvalidRegex resource key in en-US, de-DE, ja-JP
  • Fallback to English text if localization missing

Example

private bool IsPatternInvalid => 
    FilterRule.PatternType == LibraryFilterPatternType.Regex && 
    !string.IsNullOrWhiteSpace(FilterRule.Pattern) && 
    !RegexValidator.IsValidRegex(FilterRule.Pattern);

Screenshots

Invalid regex in filter rules:
Filter validation

Invalid regex in rename rules:
Rename validation

Original prompt

This section details on the original issue you should resolve

<issue_title>Check regex in the filtering and name change features for validity before saving</issue_title>
<issue_description>This would protect against potentially invalid regex's being entered with the mistake being non-obvious. If possible, feedback should be immediate.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Check regex validity in filtering and name change features Add immediate regex validation to library filter and rename forms Jan 19, 2026
Copilot AI requested a review from Lolle2000la January 19, 2026 18:47
@Lolle2000la Lolle2000la marked this pull request as ready for review January 19, 2026 19:25
@Lolle2000la Lolle2000la merged commit e050ef1 into main Jan 19, 2026
1 check passed
@Lolle2000la Lolle2000la deleted the copilot/validate-regex-on-save branch January 19, 2026 19:26
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.

Check regex in the filtering and name change features for validity before saving

2 participants