Skip to content

Commit

Permalink
Merge pull request #17 from egermano/feature/refactoring-cnpj
Browse files Browse the repository at this point in the history
New major version
  • Loading branch information
egermano authored Jan 3, 2023
2 parents 005e57a + dee7980 commit e62e179
Show file tree
Hide file tree
Showing 10 changed files with 8,591 additions and 3,638 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}
27 changes: 27 additions & 0 deletions .github/workflows/nodejs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Node.js

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: install, build, and test
run: |
npm ci
npm run lint
npm run build
npm run test
env:
CI: true
33 changes: 12 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
# Brazilian Document Validator
A Node.js module that validate brazilian documents as CPF and CPNJ.

🇧🇷 Modulo em Node.js para validação de documento CPF e CNPJ.

[![Build Status](https://travis-ci.org/egermano/brazilian-multidocument-validator.svg?branch=master)](https://travis-ci.org/egermano/brazilian-multidocument-validator)
![Node.js](https://github.com/egermano/brazilian-multidocument-validator/workflows/Node.js/badge.svg)

## Installation
```sh
npm install br-doc-validator --save
npm add br-doc-validator
# or
yarn add br-doc-validator
```

## Usage
### Javascript

```javascript
var validator = require('br-doc-validator');
let document = '00000000353';
validator.documentValidatorProm(document).then((result) => {
console.log('valid');
}, (err) => {
console.log('invalid');
});
```
```sh
Output should be 'valid'
```
const validator = require('br-doc-validator');
const document = '00000000353';
const result = validator.documentValidator(document);

### TypeScript
```typescript
import { documentValidatorProm as validator } from 'br-doc-validator';
let document = '00000000000353';
validator(document).then((result) => {
if(result) {
console.log('valid');
}, (err) => {
} else {
console.log('invalid');
});
}
```
```sh
Output should be 'valid'
Expand All @@ -41,5 +33,4 @@ Output should be 'valid'
## Test
```sh
npm run test
yarn test
```
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
collectCoverage: true,
};
Loading

0 comments on commit e62e179

Please sign in to comment.