Skip to content

Commit

Permalink
Fixed insin#27
Browse files Browse the repository at this point in the history
  • Loading branch information
lgraziani2712 committed Dec 16, 2016
1 parent 2e280bb commit 5eba0a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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])
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5eba0a7

Please sign in to comment.