fix: handle undefined or empty rules in validator#1105
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #1104 by adding logic to handle undefined and empty string rules in the validator's _parseRulesDefault method.
- Restructured the conditional logic to explicitly handle array, undefined/empty string, and other types separately
- Added
filter(Boolean)to remove empty strings from pipe-separated rules - Added a test case to verify undefined and empty rules don't cause errors
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main.ts | Modified _parseRulesDefault to handle undefined and empty string rules by converting them to empty arrays, and added filtering to remove empty values from pipe-separated rule strings |
| tests/validator.spec.ts | Added test case to verify that undefined and empty string rules are handled without errors |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Fixed #1104