From 60227abac06bca7eaac4449b8b65f145860ec20d Mon Sep 17 00:00:00 2001 From: Marton Dobos Date: Wed, 28 Aug 2019 18:54:00 +0200 Subject: [PATCH 1/2] add empty value --- lib/internal-dependencies/vanilla-masker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal-dependencies/vanilla-masker.js b/lib/internal-dependencies/vanilla-masker.js index 80d9d23a..413d2f47 100644 --- a/lib/internal-dependencies/vanilla-masker.js +++ b/lib/internal-dependencies/vanilla-masker.js @@ -29,7 +29,8 @@ //unit: opts.unit && (opts.unit.replace(/[\s]/g,'') + " ") || "", suffixUnit: opts.suffixUnit && (" " + opts.suffixUnit.replace(/[\s]/g,'')) || "", zeroCents: opts.zeroCents, - lastOutput: opts.lastOutput + lastOutput: opts.lastOutput, + emptyValue: opts.emptyValue || "0" }; opts.moneyPrecision = opts.zeroCents ? 0 : opts.precision; return opts; @@ -149,7 +150,7 @@ masked += money[i]; } masked = masked.replace(clearDelimiter, ""); - masked = masked.length ? masked : "0"; + masked = masked.length ? masked : emptyValue; if (!opts.zeroCents) { var beginCents = number.length - opts.precision, centsValue = number.substr(beginCents, opts.precision), From 1a96ab5e4ddfce479615de1071f5f58ed7e73235 Mon Sep 17 00:00:00 2001 From: Marton Dobos Date: Wed, 28 Aug 2019 19:08:54 +0200 Subject: [PATCH 2/2] empty money value in README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e57a2da..074a8387 100644 --- a/README.md +++ b/README.md @@ -484,7 +484,8 @@ Sample code ([source](https://github.com/benhurott/react-native-masked-text-samp separator: ',', delimiter: '.', unit: 'R$', - suffixUnit: '' + suffixUnit: '', + emptyValue: '', }} value={this.state.advanced} onChangeText={text => { @@ -504,6 +505,7 @@ Sample code ([source](https://github.com/benhurott/react-native-masked-text-samp | delimiter | string | no | `.` | The thousand separator | | unit | string | no | `R$` | The prefix text | | suffixUnit | string | no | `''` | The sufix text | +| emptyValue | string | no | `0` | The empty field value | #### Methods