Number / Integer checks in Kernel/System/VariableCheck #2771
stefanhaerter
started this conversation in
General
Replies: 3 comments 1 reply
|
In Principle yes. But I think that we should move into the direction of the common CPAN modules. There already is Kernel/cpan-lib/Types/Common/Numeric.pm which could be leveraged. |
0 replies
|
This would also be my preferred solution. I was just unsure if there is any specific reason for sticking to an individual solution in OTOBO or against using existing CPAN modules. |
0 replies
|
Another question is what to do with leading zeros. IMHO is would be fine to trim those. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I ran across the currently existing number check methods in
Kernel/System/VariableCheck.pm, which are:IsNumber(line 225)IsInteger(line 248)IsPositiveInteger(line 269)I think they work fine for standard cases. However, I thought about some ideas of improvement:
IsNumberwith parametersOnlyPositive(suggestion: default0)OnlyNegative(suggestion: default0)IncludeZero(suggestion: default1)(when taking this path, we could also think about uniting
IsIntegerandIsPositiveIntegerto one method with the same parameters).One thing I see less as a suggestion, but more as an actual bug: All three methods do confirm
999as a number, but not+999. Perhaps this is not very relevant, but semantically I would want to advocate for+999being a positive number as well as an integer and a positive integer.What do you think about this suggestions and opinions?
All reactions