Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added validation for '0x'-prefixed hex strings. #1147

Merged
merged 2 commits into from
Oct 13, 2019

Conversation

ayala-io
Copy link
Contributor

@ayala-io ayala-io commented Oct 11, 2019

  • Modified isHexdecimal to allow validation of hexdecimal strings prefixed with the standard '0x'. The '0x' prefix is not required but if it does exist in the string, it is still OK.
  • Updated validator.js to include a few more test cases involving the '0x' prefix

Update:

  • Added '0h' prefix as a valid hexadecimal format.

Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the contrib! 🎉

@profnandaa profnandaa merged commit 1bf0094 into validatorjs:master Oct 13, 2019
@ayala-io ayala-io deleted the add-hex-prefix-check branch October 13, 2019 14:18
@rlaace423
Copy link

This breaks previous work flow because there's someone make use of previous regex (without '0x, 0h' checking). For me, I've used my another function 'isStrictHexadecimal' which checks both 0x prefix and 2-divisible.

If there's migration note for v11 to v12, this changes should be in that.

to make it clearer..
[v11]
val.isHexadecimal('0x1234'); ==> FALSE
val.isHexadecimal('1234'); ==> TRUE

[v12]
val.isHexadecimal('0x1234') ==> TRUE
val.isHexadicimal('1234') ==> TRUE

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.

3 participants