Skip to content

Fix regex to properly validate non-negative integer strings#3

Open
endelwar wants to merge 1 commit intoskleeschulte:masterfrom
endelwar:patch-1
Open

Fix regex to properly validate non-negative integer strings#3
endelwar wants to merge 1 commit intoskleeschulte:masterfrom
endelwar:patch-1

Conversation

@endelwar
Copy link
Copy Markdown

This pull request fixes the validation logic in the function that checks whether a given value is a positive integer (or a string representing a positive integer). The previous regex pattern '/[0-9]+/' only checked for the presence of one or more numeric characters but allowed invalid inputs like "abc123" or "123abc".

The updated regex '/^[0-9]+$/' ensures that the entire string consists solely of digits, representing a valid non-negative integer. This guarantees the proper validation of inputs.

Updated the regex in the validation logic to ensure the entire string consists solely of digits, preventing invalid inputs with mixed characters.
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.

1 participant