Fixed regexrule and timezonerule inconsistencies#3
Merged
Conversation
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.
This pull request makes several improvements and fixes to the
nitro_validatorpackage, focusing on validator instance isolation, rule parsing, and increased robustness of built-in rules. The most significant change is that eachNitroValidatorinstance now gets its own independent rule registry by default, preventing rule registrations from leaking across instances. Additionally, the built-in rules are improved for correctness and clarity, and the handling of custom error messages is made safer.Validator instance isolation and registry handling:
NitroValidatornow receives a fresh copy of the built-in rule registry by default, so custom rules registered on one validator do not affect others. The registry is copied using a newcopy()method onNitroRuleRegistry. [1] [2] [3]Rule parsing and error handling:
|) and comma (,) characters cannot appear in rule arguments, and that rules needing such patterns (like regexes) must be passed as instances. [1] [2]RegexRulenow compiles its pattern at initialization, and fails validation if the pattern is invalid or missing.Built-in rule improvements and bug fixes:
IpRulenow uses precompiled patterns for IPv4 and IPv6, and checks both correctly. [1] [2]MinRule,MaxRule,BetweenRule,PositiveRule,NegativeRule) now explicitly reject boolean values, which previously could be incorrectly accepted as numbers. [1] [2] [3] [4] [5] [6] [7]Custom error message handling:
custom_messageattribute.Documentation and minor cleanups:
These changes improve the reliability, safety, and clarity of the validation framework.