Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lib/internal-dependencies/vanilla-masker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down