An open API service indexing awesome lists of open source software.

https://github.com/dimitrinicolas/text-mask-vat-id

Text Mask for VAT identification number
https://github.com/dimitrinicolas/text-mask-vat-id

text-mask tva vat

Last synced: 6 months ago
JSON representation

Text Mask for VAT identification number

Awesome Lists containing this project

README

          

# text-mask-vat-id [![Build Status][travis badge]][travis link] [![Coverage Status][coveralls badge]][coveralls link]

Text Mask function for VAT identification number.

## [Example](https://dimitrinicolas.github.io/text-mask-vat-id/example/)

Demo available here: [dimitrinicolas.github.io/text-mask-vat-id/example](https://dimitrinicolas.github.io/text-mask-vat-id/example/)

## Installation

```bash
npm i text-mask-vat-id
```

## Usage

I recommend you to add an uppercase pipe function to text-mask component:

```js
function upperCasePipe(value) {
return value.toUpperCase();
}
```

### With React.js

```jsx
import React from 'react'
import MaskedInput from 'react-text-mask'
import createVatIdMask from 'text-mask-vat-id';

const mask = createVatIdMask();

export default () => (
value.toUpperCase()} />
);
```

### In Vanilla JS

```html

function upperCasePipe(value) {
return value.toUpperCase();
}

vanillaTextMask.maskInput({
inputElement: document.getElementById('vat-input'),
mask: createVatIdMask(),
pipe: upperCasePipe
});
});

```

## Options

You can pass options as an object when creating text mask:

```js
const mask = createVatIdMask({
/** options */
});
```

- `localeFormat` (default: `false`): If the mask should add separation
characters (` `, `-`, `.` and `/`) to the VAT ID. E.g.: `"FR19845015858"` would
become `"FR 19 845 015 858"`.

## Build

Compile with Rollup:

```console
npm run build
```

Build and test:

```console
npm test
```

## Source

- [en.wikipedia.org/wiki/VAT_identification_number](https://en.wikipedia.org/wiki/VAT_identification_number)
- [www.gov.uk/guidance/vat-eu-country-codes-vat-numbers-and-vat-in-other-languages](https://www.gov.uk/guidance/vat-eu-country-codes-vat-numbers-and-vat-in-other-languages)

## Related

- [`text-mask`](https://github.com/text-mask/text-mask) - Input mask for React, Angular, Ember, Vue, & plain JavaScript

## License

This project is licensed under the [MIT license](LICENSE).

[travis badge]: https://travis-ci.org/dimitrinicolas/text-mask-vat-id.svg?branch=master
[travis link]: https://travis-ci.org/dimitrinicolas/text-mask-vat-id
[coveralls badge]: https://coveralls.io/repos/github/dimitrinicolas/text-mask-vat-id/badge.svg?branch=master
[coveralls link]: https://coveralls.io/github/dimitrinicolas/text-mask-vat-id?branch=master