Number / Integer checks in Kernel/System/VariableCheck #2771
stefanhaerter
started this conversation in
General
Replies: 2 comments
-
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. |
Beta Was this translation helpful? Give feedback.
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. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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:
IsNumber
with parametersOnlyPositive
(suggestion: default0
)OnlyNegative
(suggestion: default0
)IncludeZero
(suggestion: default1
)(when taking this path, we could also think about uniting
IsInteger
andIsPositiveInteger
to 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
999
as a number, but not+999
. Perhaps this is not very relevant, but semantically I would want to advocate for+999
being a positive number as well as an integer and a positive integer.What do you think about this suggestions and opinions?
Beta Was this translation helpful? Give feedback.
All reactions