diff options
Diffstat (limited to 'app/assets/javascripts/lib/utils/number_utils.js')
-rw-r--r-- | app/assets/javascripts/lib/utils/number_utils.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/number_utils.js b/app/assets/javascripts/lib/utils/number_utils.js index 63feb6f9b1d..e3500d02a79 100644 --- a/app/assets/javascripts/lib/utils/number_utils.js +++ b/app/assets/javascripts/lib/utils/number_utils.js @@ -171,3 +171,13 @@ export const formattedChangeInPercent = (firstY, lastY, { nonFiniteResult = '-' export const isNumeric = (value) => { return !Number.isNaN(parseInt(value, 10)); }; + +const numberRegex = /^[0-9]+$/; + +/** + * Checks whether the value is a positive number or 0, or a string with equivalent value + * + * @param value + * @return {boolean} + */ +export const isPositiveInteger = (value) => numberRegex.test(value); |