• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

reactivando / validations-br / 17783612896

17 Sep 2025 01:17AM UTC coverage: 91.96% (-0.4%) from 92.345%
17783612896

push

github

web-flow
feat: optimize build with tsdown (#49)

* feat: optimize build with tsdown

- Replace tsc with tsdown for a smaller bundle size.
- Generate both CJS and ESM modules.
- Update documentation to use pnpm.

* feat: optimize build with tsdown and add e2e test

- Replace tsc with tsdown for a smaller bundle size.
- Generate both CJS and ESM modules.
- Update documentation to use pnpm.
- Add an example project to test the built package.
- Add a GitHub Action to run e2e tests on pull requests.

* feat: optimize build, add e2e tests and bundle analysis

- Replace tsc with tsdown for a smaller, optimized bundle.
- Generate both CJS and ESM modules for modern compatibility.
- Refactor `validateIE` to use dynamic imports, significantly reducing the main bundle size.
- Add `"sideEffects": false` to package.json to enable more aggressive tree-shaking.
- Add an example project to perform end-to-end testing on the built package.
- Add a GitHub Action to automate e2e tests on pull requests.
- Integrate a bundle analyzer (`rollup-plugin-visualizer`) to inspect bundle composition.
- Update documentation to include `pnpm` and correct contribution guidelines.
- Update .gitignore to exclude build artifacts and local dependencies.

* feat: optimize build with tsdown and add e2e test

- Replace tsc with tsdown for a smaller, optimized bundle.
- Generate both CJS and ESM modules for modern compatibility.
- Add an example project to perform end-to-end testing on the built package.
- Add a GitHub Action to automate e2e tests on pull requests.
- Integrate a bundle analyzer (`rollup-plugin-visualizer`) to inspect bundle composition.
- Add `"sideEffects": false` to package.json to enable more aggressive tree-shaking.
- Update documentation to include `pnpm` and correct contribution guidelines.
- Update .gitignore to exclude build artifacts and local dependencies.
- Keep `validateIE` synchronous to maintain API consistency, as requested.

* feat: optimize build for tree-shaking and... (continued)

222 of 252 branches covered (88.1%)

Branch coverage included in aggregate %.

693 of 743 relevant lines covered (93.27%)

9.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.17
/src/validations/validateCNH.ts
1
import { isRepeated } from './utils';
1✔
2

3
/**
4
 * The function `validateCNH` validates a Brazilian driver's license number (CNH).
5
 * @param {string} value - The `value` parameter is a string that represents the CNH (Carteira Nacional
6
 * de Habilitação) number to be validated. It can be formatted with or without punctuation.
7
 * @returns The function `validateCNH` returns a boolean value, indicating whether the provided CNH is
8
 * valid or not.
9
 */
10
export function validateCNH(value: string) {
1✔
11
  const cnh = String(value).replace(/\D/g, '');
10✔
12

13
  if (cnh.length !== 11 || isRepeated(cnh)) {
10✔
14
    return false;
6✔
15
  }
6✔
16

17
  let v = 0;
4✔
18
  let j = 9;
4✔
19
  for (let i = 0; i < 9; ++i) {
10✔
20
    v += parseInt(cnh.charAt(i), 10) * j--;
36✔
21
  }
36✔
22

23
  let dv1 = v % 11;
4✔
24
  let dsc = 0;
4✔
25
  if (dv1 >= 10) {
10!
26
    dv1 = 0;
×
27
    dsc = 2;
×
28
  }
✔
29

30
  v = 0;
4✔
31
  j = 1;
4✔
32
  for (let i = 0; i < 9; ++i) {
10✔
33
    v += parseInt(cnh.charAt(i), 10) * j++;
36✔
34
  }
36✔
35

36
  let dv2 = v % 11;
4✔
37
  if (dv2 >= 10) {
10!
38
    dv2 = 0;
×
39
  }
✔
40

41
  dv2 -= dsc;
4✔
42

43
  if (dv2 < 0) {
10!
44
    dv2 += 11;
×
45
  }
✔
46

47
  return (
4✔
48
    dv1 === parseInt(cnh.charAt(9), 10) && dv2 === parseInt(cnh.charAt(10), 10)
10✔
49
  );
50
}
10✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc