-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Consider adding a mod()
function or similar to OTTL
#37880
Comments
Pinging code owners: See Adding Labels via Comments if you do not have permissions to add labels yourself. |
I wonder if we should build this into OTTL's arithmetic capabilities so you can do |
I mentioned the Luhn algorithm specifically only because it's used as part of validation for almost all credit card schemes, but if we can reproduce the Luhn check with a math function, that would be fine. (It would be cool to have an example snippet in the docs, though.) |
Although adding the reminder operator capability to OTTL would be useful, I think that wouldn't be enough for calculating the Luhn algorithm. If I'm not mistaken, it requires extra steps, such as looping through the number digits, double values, etc. which isn't supported by OTTL. That said, I'd go with a specific function |
I could look into implementing this |
The PR should be ready for review now - I implemented it as a specific |
Hi @bixu, just to double check, do you need validating numbers using the Luhn algorithm or calculating/getting the check digit? I initially thought it was the second option, but I think I misunderstood it. If that's a validation function, I'd name it |
@edmocosta, I think the most common use-case here is to check if a number is (probably) a valid CC number. So I think @bacherfl's PR will do the trick here. I agree that the function name should clearly indicate this is a bool. What about |
Thanks for confirming @bixu! I think |
I don't have a strong opinion about the name other than signaling that the return value is a boolean. It probably makes sense to follow the style of existing functions, so I'm happy to work with whatever the maintainers decide. |
Most of our boolean function start with |
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
One common use-case for OTTL is making sensitive key values. For example, credit card numbers. Using Regexes alone can be difficult and prone to bugs.
Describe the solution you'd like
Some algorithm like the Luhn algorithm would make OTTL easier to use in the context of redaction or masking of values like credit card numbers.
Describe alternatives you've considered
Regex functions do exist in OTTL, but it's relatively easy to introduce bugs when using "pure" regex. An additional layer of checking using something like Luhn/mod 10 could increase correctness.
The text was updated successfully, but these errors were encountered: