Browse Source

[IMP] currency formating

Gogs 7 năm trước cách đây
mục cha
commit
263a722869
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      src/components/filters/currency.js

+ 4 - 0
src/components/filters/currency.js

@@ -8,6 +8,10 @@ const currency = (value = 0, symbol = '$', symbolPosition = 'before', thousandsS
         decimalPlaces = 2
     }
 
+    if (!!(`${thousandsSeparator}${decimalSeparator}`).replace(/\.,|,\./g, '')) {
+        throw new Error('Same thousands and decimal separator is not allowed')
+    }
+
     value = value.split('.')
 
     value[0] = value[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, `$1${thousandsSeparator}`)