From 5eba0a7f1582a476b191f433edbf163dd21f8b85 Mon Sep 17 00:00:00 2001 From: Luciano Graziani Date: Fri, 16 Dec 2016 00:28:24 -0300 Subject: [PATCH] Fixed #27 --- lib/index.js | 4 ++-- test/index.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 3c7c31f..96d158e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -177,7 +177,7 @@ Pattern.prototype.isEditableIndex = function isEditableIndex(index) { * @return {boolean} */ Pattern.prototype.isValidAtIndex = function isValidAtIndex(char, index) { - return this.formatCharacters[this.pattern[index]].validate(char) + return this.isEditableIndex(index) && this.formatCharacters[this.pattern[index]].validate(char) } Pattern.prototype.transform = function transform(char, index) { @@ -498,7 +498,7 @@ InputMask.prototype.getValue = function getValue() { InputMask.prototype.getRawValue = function getRawValue() { var rawValue = [] for (var i = 0; i < this.value.length; i++) { - if (this.pattern._editableIndices[i] === true) { + if (this.pattern.isValidAtIndex(this.value[i], i)) { rawValue.push(this.value[i]) } } diff --git a/test/index.js b/test/index.js index 34f473e..2fbf424 100644 --- a/test/index.js +++ b/test/index.js @@ -27,6 +27,13 @@ test('README example', function(t) { t.end() }) +test('getRawValue', function(t) { + t.plan(1) + var mask = new InputMask({pattern: '1111 1111', value: '98781'}) + + t.equal(mask.getRawValue(), '98781', 'Current value without non-editable pattern characters') +}) + test('formatValueToPattern', function(t) { t.plan(7)