-
Notifications
You must be signed in to change notification settings - Fork 137
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
fix(Byte): update isHex validator #543
Conversation
The base64 and hex validators are not guaranteeed to work. There are some false positive cases, so instead add a type header to the string, so a user can specify what the encoding of the string is.
Is there anything else that is needed for this PR to be mergeable? |
Isn't that a breaking change? |
Well it changes the functionality, yes. But the previous parsing didn't work in subtle ways. |
Instead of breaking the existing ones, we can have a better unit tests or two different scalars like one for Hex and another one for Base64. What do you think? |
Yeah I can create 2 new Byte scalars. But would we deprecate |
There were cases where the hex regex validator would return true for a value that was acutally base64 encoded. Added tests for this case and updated the validator.
I was able to fix the hex validator, which would sometime return true for base64 values. |
|
@rufman Something is wrong with the const buf = Buffer.from([4, 8, 15, 16, 23, 42]);
const hex = buf.toString("hex");
console.log(hex); // 04080f10172a
console.log(hexValidator(hex)); // false |
Hmm leading 0 is the issue. fix is here: #717 |
The base64 and hex validators are not guaranteeed to work.
There are some false positive cases, so instead add a type header to
the string, so a user can specify what the encoding of the string is.