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

reactivando / validations-br / 17783464668

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

Pull #49

github

web-flow
Merge 7621688cf into d0028a8f8
Pull Request #49: feat: optimize build with tsdown

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

85.71
/src/validations/utils.ts
1
/**
2
 * The function `isRepeated` checks if a given string consists of repeated characters.
3
 * @param {string} ref - The `ref` parameter is a string that you want to check for repeated
4
 * characters.
5
 * @returns a boolean value.
6
 */
7
export const isRepeated = (ref: string) => {
1✔
8
  const ret = ref.replace(new RegExp(ref[0], 'g'), '').trim().length === 0;
64✔
9
  return ret;
64✔
10
};
64✔
11

12
/**
13
 * The `mod11` function calculates the MOD11 checksum for a given value with a specified limit.
14
 * @param {string} clearValue - The `clearValue` parameter is a string that represents the numeric
15
 * value for which you want to calculate the MOD11 checksum. It should not contain any non-digit
16
 * characters.
17
 * @param {number} limite - The `limite` parameter in the `mod11` function represents the upper limit
18
 * for the multiplier used in the calculation. The multiplier starts at 2 and increments by 1 for each
19
 * digit of the input `clearValue`. When the multiplier exceeds the `limite`, it resets back to 2.
20
 * @returns The `mod11` function returns a number, which is the calculated check digit (DV).
21
 */
22
export const mod11 = (clearValue: string, limite: number): number => {
1✔
23
  const valor = String(clearValue).replace(/\D/g, '');
26✔
24
  let sum = 0;
26✔
25
  let mult = 2;
26✔
26

27
  for (let i = valor.length - 1; i >= 0; i--) {
26✔
28
    sum += mult * +valor[i];
247✔
29
    if (++mult > limite) {
247!
30
      mult = 2;
×
31
    }
×
32
  }
247✔
33
  const dv = ((sum * 10) % 11) % 10;
26✔
34
  return dv;
26✔
35
};
26✔
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