Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/no mask #261

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
20 changes: 20 additions & 0 deletions __tests__/mask/no-mask.mask.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { NoMask } from '../../lib/masks'

test('getType results no-mask', () => {
var expected = 'no-mask'
var received = NoMask.getType()

expect(received).toBe(expected)
})

test('abc123$%.,* results abc123$%.,* and raw value abc123$%.,*', () => {
var mask = new NoMask()
var expected = 'abc123$%.,*'
var received = mask.getValue('abc123$%.,*')

var expectedRawValue = 'abc123$%.,*'
var receivedRawValue = mask.getRawValue(received)

expect(received).toBe(expected)
expect(receivedRawValue).toBe(expectedRawValue)
})
2 changes: 1 addition & 1 deletion dist/lib/masks/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/lib/masks/no-mask.mask.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ export type TextInputMaskTypeProp =
| 'cpf'
| 'cnpj'
| 'zip-code'
| 'no-mask'
| 'only-numbers'
| 'money'
| 'cel-phone'
| 'datetime'
| 'no-mask'
| 'custom'

// Option prop of TextInputMask.
Expand Down
2 changes: 2 additions & 0 deletions lib/masks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import MoneyMask from './money.mask'
import OnlyNumbersMask from './only-numbers.mask'
import ZipCodeMask from './zip-code.mask'
import CreditCardMask from './credit-card.mask'
import NoMask from './no-mask.mask'

module.exports.CelPhoneMask = CelPhoneMask
module.exports.CnpjMask = CnpjMask
Expand All @@ -17,3 +18,4 @@ module.exports.MoneyMask = MoneyMask
module.exports.OnlyNumbersMask = OnlyNumbersMask
module.exports.ZipCodeMask = ZipCodeMask
module.exports.CreditCardMask = CreditCardMask
module.exports.NoMask = NoMask
23 changes: 23 additions & 0 deletions lib/masks/no-mask.mask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import BaseMask from './_base.mask'

export default class OnlyNumbersMask extends BaseMask {
static getType() {
return 'no-mask'
}

getValue(value, settings) {
return String(value)
}

getRawValue(maskedValue, settings) {
return String(maskedValue)
}

validate(value, settings) {
return true
}

getMask(value, settings) {
return ''
}
}