Skip to content

Conversation

@YufJi
Copy link
Contributor

@YufJi YufJi commented Dec 23, 2025

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new regex validation rule to the validator package, providing an alternative way to validate values against regular expressions with an object-based pattern and flags specification.

  • Adds a regex validator function that accepts pattern and optional flags as an object
  • Registers the regex rule with appropriate trigger and error message configuration
  • Implements error handling for invalid regex patterns

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/validator/src/builtIn/validators.ts Adds the regex validator function with object-based pattern/flags parameters and exports it in the validators object
packages/validator/src/builtIn/rules.ts Registers the regex rule with 'input+blur' trigger and reuses the existing pattern error message

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


try {
return new RegExp(reg.pattern, reg.flags).test(value);
} catch (error) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The try-catch block silently swallows errors when an invalid regex pattern is provided. This makes it difficult to debug issues with malformed regex patterns. Consider logging the error or providing feedback to help developers identify invalid regex patterns during development.

Suggested change
} catch (error) {
} catch (error) {
// Log invalid regex patterns to aid debugging while still returning false to the caller.
console.error('Invalid regular expression in regex validator:', {
pattern: reg && reg.pattern,
flags: reg && reg.flags,
error,
});

Copilot uses AI. Check for mistakes.
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.

2 participants