@mmb-digital/shared-libs-auto 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/formaters/formatBankAccount/formatBankAccount.d.ts +11 -0
  2. package/dist/formaters/formatBankAccount/formatBankAccount.js +8 -0
  3. package/dist/formaters/formatBankAccount/formatBankAccount.js.map +1 -0
  4. package/dist/formaters/formatCzZipCode/formatCzZipCode.d.ts +4 -0
  5. package/dist/formaters/formatCzZipCode/formatCzZipCode.js +11 -0
  6. package/dist/formaters/formatCzZipCode/formatCzZipCode.js.map +1 -0
  7. package/dist/formaters/index.d.ts +2 -0
  8. package/dist/formaters/index.js +3 -0
  9. package/dist/formaters/index.js.map +1 -0
  10. package/dist/hooks/index.d.ts +1 -0
  11. package/dist/hooks/index.js +2 -0
  12. package/dist/hooks/index.js.map +1 -0
  13. package/dist/hooks/useToggle/useToggle.d.ts +7 -0
  14. package/dist/hooks/useToggle/useToggle.js +28 -0
  15. package/dist/hooks/useToggle/useToggle.js.map +1 -0
  16. package/dist/index.d.ts +3 -0
  17. package/dist/index.js +4 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/validators/index.d.ts +13 -0
  20. package/dist/validators/index.js +14 -0
  21. package/dist/validators/index.js.map +1 -0
  22. package/dist/validators/isBoolean/isBoolean.d.ts +4 -0
  23. package/dist/validators/isBoolean/isBoolean.js +5 -0
  24. package/dist/validators/isBoolean/isBoolean.js.map +1 -0
  25. package/dist/validators/isDIC/isDIC.d.ts +4 -0
  26. package/dist/validators/isDIC/isDIC.js +11 -0
  27. package/dist/validators/isDIC/isDIC.js.map +1 -0
  28. package/dist/validators/isEmpty/isEmpty.d.ts +4 -0
  29. package/dist/validators/isEmpty/isEmpty.js +20 -0
  30. package/dist/validators/isEmpty/isEmpty.js.map +1 -0
  31. package/dist/validators/isEmptyString/isEmptyString.d.ts +4 -0
  32. package/dist/validators/isEmptyString/isEmptyString.js +6 -0
  33. package/dist/validators/isEmptyString/isEmptyString.js.map +1 -0
  34. package/dist/validators/isICO/isICO.d.ts +4 -0
  35. package/dist/validators/isICO/isICO.js +32 -0
  36. package/dist/validators/isICO/isICO.js.map +1 -0
  37. package/dist/validators/isModulo11/isModulo11.d.ts +4 -0
  38. package/dist/validators/isModulo11/isModulo11.js +13 -0
  39. package/dist/validators/isModulo11/isModulo11.js.map +1 -0
  40. package/dist/validators/isNull/isNull.d.ts +4 -0
  41. package/dist/validators/isNull/isNull.js +5 -0
  42. package/dist/validators/isNull/isNull.js.map +1 -0
  43. package/dist/validators/isNullOrUndefined/isNullOrUndefined.d.ts +4 -0
  44. package/dist/validators/isNullOrUndefined/isNullOrUndefined.js +5 -0
  45. package/dist/validators/isNullOrUndefined/isNullOrUndefined.js.map +1 -0
  46. package/dist/validators/isNumber/isNumber.d.ts +4 -0
  47. package/dist/validators/isNumber/isNumber.js +5 -0
  48. package/dist/validators/isNumber/isNumber.js.map +1 -0
  49. package/dist/validators/isNumberOrString/isNumberOrString.d.ts +4 -0
  50. package/dist/validators/isNumberOrString/isNumberOrString.js +6 -0
  51. package/dist/validators/isNumberOrString/isNumberOrString.js.map +1 -0
  52. package/dist/validators/isObject/isObject.d.ts +4 -0
  53. package/dist/validators/isObject/isObject.js +6 -0
  54. package/dist/validators/isObject/isObject.js.map +1 -0
  55. package/dist/validators/isString/isString.d.ts +4 -0
  56. package/dist/validators/isString/isString.js +5 -0
  57. package/dist/validators/isString/isString.js.map +1 -0
  58. package/dist/validators/isUndefined/isUndefined.d.ts +4 -0
  59. package/dist/validators/isUndefined/isUndefined.js +5 -0
  60. package/dist/validators/isUndefined/isUndefined.js.map +1 -0
  61. package/package.json +60 -0
@@ -0,0 +1,11 @@
1
+ type Nullable<T> = T | null;
2
+ interface BankAccountInput {
3
+ number: string;
4
+ bankCode: string;
5
+ prefix?: Nullable<string>;
6
+ }
7
+ /**
8
+ * Formats a bank account input into a standardized string representation.
9
+ */
10
+ export declare const formatBankAccount: ({ prefix, number, bankCode }: BankAccountInput) => string;
11
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Formats a bank account input into a standardized string representation.
3
+ */
4
+ export const formatBankAccount = ({ prefix, number, bankCode }) => {
5
+ const accountNumber = [String(number).trim(), bankCode.trim()].join('/');
6
+ return [prefix, accountNumber].filter(Boolean).join('-');
7
+ };
8
+ //# sourceMappingURL=formatBankAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatBankAccount.js","sourceRoot":"","sources":["../../../src/formaters/formatBankAccount/formatBankAccount.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAoB,EAAE,EAAE;IAClF,MAAM,aAAa,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxE,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1D,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Formats a Czech zip code by adding a space between the third and fourth digits.
3
+ */
4
+ export declare const formatCzZipCode: (value: number | string | null | undefined) => string;
@@ -0,0 +1,11 @@
1
+ import { isNullOrUndefined } from '../../validators/index.js';
2
+ const ZIP_CODE_REGEX = /(\d{3})(\d{2})/;
3
+ /**
4
+ * Formats a Czech zip code by adding a space between the third and fourth digits.
5
+ */
6
+ export const formatCzZipCode = (value) => {
7
+ if (isNullOrUndefined(value))
8
+ return '';
9
+ return value.toString().replace(ZIP_CODE_REGEX, `$1 $2`);
10
+ };
11
+ //# sourceMappingURL=formatCzZipCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatCzZipCode.js","sourceRoot":"","sources":["../../../src/formaters/formatCzZipCode/formatCzZipCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAyC,EAAE,EAAE;IAC3E,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACvC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AAC1D,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { formatBankAccount } from './formatBankAccount/formatBankAccount.js';
2
+ export { formatCzZipCode } from './formatCzZipCode/formatCzZipCode.js';
@@ -0,0 +1,3 @@
1
+ export { formatBankAccount } from './formatBankAccount/formatBankAccount.js';
2
+ export { formatCzZipCode } from './formatCzZipCode/formatCzZipCode.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formaters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAA"}
@@ -0,0 +1 @@
1
+ export { useToggle } from './useToggle/useToggle.js';
@@ -0,0 +1,2 @@
1
+ export { useToggle } from './useToggle/useToggle.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A custom hook that manages a boolean toggle state.
3
+ */
4
+ export declare const useToggle: (defaultState?: boolean) => readonly [boolean, () => void, {
5
+ readonly open: () => void;
6
+ readonly close: () => void;
7
+ }, import("react").Dispatch<import("react").SetStateAction<boolean>>];
@@ -0,0 +1,28 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ /**
3
+ * A custom hook that manages a boolean toggle state.
4
+ */
5
+ export const useToggle = (defaultState = false) => {
6
+ const [isOpen, setIsOpen] = useState(defaultState);
7
+ const isMounted = useRef(false);
8
+ useEffect(() => {
9
+ isMounted.current = true;
10
+ return () => {
11
+ isMounted.current = false;
12
+ };
13
+ }, []);
14
+ const toggle = useCallback(() => {
15
+ if (isMounted.current)
16
+ setIsOpen(value => !value);
17
+ }, []);
18
+ const open = useCallback(() => {
19
+ if (isMounted.current)
20
+ setIsOpen(true);
21
+ }, []);
22
+ const close = useCallback(() => {
23
+ if (isMounted.current)
24
+ setIsOpen(false);
25
+ }, []);
26
+ return useMemo(() => [isOpen, toggle, { open, close }, setIsOpen], [isOpen, toggle, close, open]);
27
+ };
28
+ //# sourceMappingURL=useToggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToggle.js","sourceRoot":"","sources":["../../../src/hooks/useToggle/useToggle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEzE;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,YAAY,GAAG,KAAK,EAAE,EAAE;IAChD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAA;IAClD,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAE/B,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,OAAO,GAAG,IAAI,CAAA;QAExB,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,OAAO,GAAG,KAAK,CAAA;QAC3B,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,SAAS,CAAC,OAAO;YAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA;IACnD,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5B,IAAI,SAAS,CAAC,OAAO;YAAE,SAAS,CAAC,IAAI,CAAC,CAAA;IACxC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,IAAI,SAAS,CAAC,OAAO;YAAE,SAAS,CAAC,KAAK,CAAC,CAAA;IACzC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,SAAS,CAAU,EAC3D,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAC9B,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './formaters/index.js';
2
+ export * from './hooks/index.js';
3
+ export * from './validators/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from './formaters/index.js';
2
+ export * from './hooks/index.js';
3
+ export * from './validators/index.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,13 @@
1
+ export { isBoolean } from './isBoolean/isBoolean.js';
2
+ export { isDIC } from './isDIC/isDIC.js';
3
+ export { isEmpty } from './isEmpty/isEmpty.js';
4
+ export { isEmptyString } from './isEmptyString/isEmptyString.js';
5
+ export { isICO } from './isICO/isICO.js';
6
+ export { isModulo11 } from './isModulo11/isModulo11.js';
7
+ export { isNull } from './isNull/isNull.js';
8
+ export { isNullOrUndefined } from './isNullOrUndefined/isNullOrUndefined.js';
9
+ export { isNumber } from './isNumber/isNumber.js';
10
+ export { isNumberOrString } from './isNumberOrString/isNumberOrString.js';
11
+ export { isObject } from './isObject/isObject.js';
12
+ export { isString } from './isString/isString.js';
13
+ export { isUndefined } from './isUndefined/isUndefined.js';
@@ -0,0 +1,14 @@
1
+ export { isBoolean } from './isBoolean/isBoolean.js';
2
+ export { isDIC } from './isDIC/isDIC.js';
3
+ export { isEmpty } from './isEmpty/isEmpty.js';
4
+ export { isEmptyString } from './isEmptyString/isEmptyString.js';
5
+ export { isICO } from './isICO/isICO.js';
6
+ export { isModulo11 } from './isModulo11/isModulo11.js';
7
+ export { isNull } from './isNull/isNull.js';
8
+ export { isNullOrUndefined } from './isNullOrUndefined/isNullOrUndefined.js';
9
+ export { isNumber } from './isNumber/isNumber.js';
10
+ export { isNumberOrString } from './isNumberOrString/isNumberOrString.js';
11
+ export { isObject } from './isObject/isObject.js';
12
+ export { isString } from './isString/isString.js';
13
+ export { isUndefined } from './isUndefined/isUndefined.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is a valid boolean.
3
+ */
4
+ export declare const isBoolean: (value: unknown) => value is boolean;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks if the given value is a valid boolean.
3
+ */
4
+ export const isBoolean = (value) => typeof value === 'boolean';
5
+ //# sourceMappingURL=isBoolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isBoolean.js","sourceRoot":"","sources":["../../../src/validators/isBoolean/isBoolean.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAoB,EAAE,CAAC,OAAO,KAAK,KAAK,SAAS,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is a valid DIC (Daňové identifikační číslo) number.
3
+ */
4
+ export declare const isDIC: (value: string | null | undefined) => boolean;
@@ -0,0 +1,11 @@
1
+ import { isNullOrUndefined } from '../index.js';
2
+ const DIC_REGEX = /^[A-Z]{2}\d{8,10}$/;
3
+ /**
4
+ * Checks if the given value is a valid DIC (Daňové identifikační číslo) number.
5
+ */
6
+ export const isDIC = (value) => {
7
+ if (isNullOrUndefined(value))
8
+ return false;
9
+ return DIC_REGEX.test(value);
10
+ };
11
+ //# sourceMappingURL=isDIC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDIC.js","sourceRoot":"","sources":["../../../src/validators/isDIC/isDIC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,SAAS,GAAG,oBAAoB,CAAA;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAgC,EAAW,EAAE;IACjE,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAE1C,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is empty.
3
+ */
4
+ export declare const isEmpty: <T>(value: T | undefined | null) => value is undefined | null;
@@ -0,0 +1,20 @@
1
+ import { isEmptyString, isNullOrUndefined, isNumber, isObject, isString } from '../index.js';
2
+ /**
3
+ * Checks if the given value is empty.
4
+ */
5
+ export const isEmpty = (value) => {
6
+ if (isString(value) && isEmptyString(value))
7
+ return true;
8
+ if (isNumber(value) && value === 0)
9
+ return true;
10
+ if (isNullOrUndefined(value))
11
+ return true;
12
+ if (Array.isArray(value)) {
13
+ if (value.length === 0)
14
+ return true;
15
+ if (value.every(isEmpty))
16
+ return true;
17
+ }
18
+ return isObject(value) && Object.keys(value).length === 0;
19
+ };
20
+ //# sourceMappingURL=isEmpty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEmpty.js","sourceRoot":"","sources":["../../../src/validators/isEmpty/isEmpty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE5F;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAI,KAA2B,EAA6B,EAAE;IACnF,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACxD,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC/C,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACzC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACnC,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAA;IACvC,CAAC;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;AAC3D,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is an empty string.
3
+ */
4
+ export declare const isEmptyString: (value: unknown) => value is "";
@@ -0,0 +1,6 @@
1
+ import { isString } from '../index.js';
2
+ /**
3
+ * Checks if the given value is an empty string.
4
+ */
5
+ export const isEmptyString = (value) => isString(value) && value === '';
6
+ //# sourceMappingURL=isEmptyString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEmptyString.js","sourceRoot":"","sources":["../../../src/validators/isEmptyString/isEmptyString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAe,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is a valid ICO (Identifikační číslo organizace).
3
+ */
4
+ export declare const isICO: (value: string | number | null | undefined) => boolean;
@@ -0,0 +1,32 @@
1
+ import { isNullOrUndefined, isNumber } from '../index.js';
2
+ // https://www.zizka.ch/pages/programming/ruzne/rodne-cislo-identifikacni-cislo-rc-ico-kontrola-validace.html
3
+ /**
4
+ * Checks if the given value is a valid ICO (Identifikační číslo organizace).
5
+ */
6
+ export const isICO = (value) => {
7
+ if (isNullOrUndefined(value))
8
+ return false;
9
+ const parsedNumber = Number(value);
10
+ if (!isNumber(parsedNumber))
11
+ return false;
12
+ const numbers = parsedNumber.toString().split('').map(Number);
13
+ if (numbers.length !== 8)
14
+ return false;
15
+ const factors = [8, 7, 6, 5, 4, 3, 2];
16
+ // checksum consist of first 7 digits
17
+ const sum = factors.reduce((accumulator, factor, index) => {
18
+ const product = factor * (numbers[index] ?? 1);
19
+ return accumulator + product;
20
+ }, 0);
21
+ const checksum = (() => {
22
+ const remainder = sum % 11;
23
+ if (remainder === 0 || remainder === 10)
24
+ return 1;
25
+ if (remainder === 1)
26
+ return 0;
27
+ return 11 - remainder;
28
+ })();
29
+ // the last digit of ICO is checking number
30
+ return numbers[numbers.length - 1] === checksum;
31
+ };
32
+ //# sourceMappingURL=isICO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isICO.js","sourceRoot":"","sources":["../../../src/validators/isICO/isICO.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEzD,6GAA6G;AAE7G;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAyC,EAAW,EAAE;IAC1E,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAE1C,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAElC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QAAE,OAAO,KAAK,CAAA;IACzC,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAE7D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAEtC,MAAM,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAErC,qCAAqC;IACrC,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;QACxD,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAC9C,OAAO,WAAW,GAAG,OAAO,CAAA;IAC9B,CAAC,EAAE,CAAC,CAAC,CAAA;IAEL,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE;QACrB,MAAM,SAAS,GAAG,GAAG,GAAG,EAAE,CAAA;QAC1B,IAAI,SAAS,KAAK,CAAC,IAAI,SAAS,KAAK,EAAE;YAAE,OAAO,CAAC,CAAA;QACjD,IAAI,SAAS,KAAK,CAAC;YAAE,OAAO,CAAC,CAAA;QAC7B,OAAO,EAAE,GAAG,SAAS,CAAA;IACvB,CAAC,CAAC,EAAE,CAAA;IAEJ,2CAA2C;IAC3C,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,QAAQ,CAAA;AACjD,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given number is valid according to the Modulo 11 algorithm.
3
+ */
4
+ export declare const isModulo11: (number: number) => boolean;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Checks if the given number is valid according to the Modulo 11 algorithm.
3
+ */
4
+ export const isModulo11 = (number) => {
5
+ const numbers = number.toString().split('').map(Number);
6
+ const factors = [6, 3, 7, 9, 10, 5, 8, 4, 2, 1]; // weighted checking factors
7
+ const checksum = numbers.reduce((sum, digit, index) => {
8
+ const product = digit * (factors[index] ?? 1);
9
+ return sum + product;
10
+ }, 0);
11
+ return checksum % 11 === 0;
12
+ };
13
+ //# sourceMappingURL=isModulo11.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isModulo11.js","sourceRoot":"","sources":["../../../src/validators/isModulo11/isModulo11.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAc,EAAW,EAAE;IACpD,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAEvD,MAAM,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA,CAAC,4BAA4B;IAC5E,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACpD,MAAM,OAAO,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAC7C,OAAO,GAAG,GAAG,OAAO,CAAA;IACtB,CAAC,EAAE,CAAC,CAAC,CAAA;IAEL,OAAO,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAA;AAC5B,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is null.
3
+ */
4
+ export declare const isNull: (value: unknown) => value is null;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks if the given value is null.
3
+ */
4
+ export const isNull = (value) => value === null;
5
+ //# sourceMappingURL=isNull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNull.js","sourceRoot":"","sources":["../../../src/validators/isNull/isNull.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,KAAK,KAAK,IAAI,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is null or undefined.
3
+ */
4
+ export declare const isNullOrUndefined: (value: unknown) => value is null | undefined;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks if the given value is null or undefined.
3
+ */
4
+ export const isNullOrUndefined = (value) => value === null || value === undefined;
5
+ //# sourceMappingURL=isNullOrUndefined.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNullOrUndefined.js","sourceRoot":"","sources":["../../../src/validators/isNullOrUndefined/isNullOrUndefined.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAA6B,EAAE,CAC7E,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is a valid number.
3
+ */
4
+ export declare const isNumber: (value: unknown) => value is number;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks if the given value is a valid number.
3
+ */
4
+ export const isNumber = (value) => typeof value === 'number';
5
+ //# sourceMappingURL=isNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNumber.js","sourceRoot":"","sources":["../../../src/validators/isNumber/isNumber.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is a valid number or string.
3
+ */
4
+ export declare const isNumberOrString: (value: unknown) => value is number | string;
@@ -0,0 +1,6 @@
1
+ import { isNumber, isString } from '../index.js';
2
+ /**
3
+ * Checks if the given value is a valid number or string.
4
+ */
5
+ export const isNumberOrString = (value) => isNumber(value) || isString(value);
6
+ //# sourceMappingURL=isNumberOrString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNumberOrString.js","sourceRoot":"","sources":["../../../src/validators/isNumberOrString/isNumberOrString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA4B,EAAE,CAC3E,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is a valid object.
3
+ */
4
+ export declare const isObject: <T extends Record<string, unknown>>(value: unknown) => value is T;
@@ -0,0 +1,6 @@
1
+ // `typeof null` and `typeof object` are equal 'object` so we need to include them in check
2
+ /**
3
+ * Checks if the given value is a valid object.
4
+ */
5
+ export const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
6
+ //# sourceMappingURL=isObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isObject.js","sourceRoot":"","sources":["../../../src/validators/isObject/isObject.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAE3F;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAoC,KAAc,EAAc,EAAE,CACxF,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is a valid string.
3
+ */
4
+ export declare const isString: (value: unknown) => value is string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks if the given value is a valid string.
3
+ */
4
+ export const isString = (value) => typeof value === 'string';
5
+ //# sourceMappingURL=isString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isString.js","sourceRoot":"","sources":["../../../src/validators/isString/isString.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks if the given value is undefined.
3
+ */
4
+ export declare const isUndefined: (value: unknown) => value is undefined;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks if the given value is undefined.
3
+ */
4
+ export const isUndefined = (value) => value === undefined;
5
+ //# sourceMappingURL=isUndefined.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUndefined.js","sourceRoot":"","sources":["../../../src/validators/isUndefined/isUndefined.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAsB,EAAE,CAAC,KAAK,KAAK,SAAS,CAAA"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@mmb-digital/shared-libs-auto",
3
+ "version": "0.0.1",
4
+ "description": "MMB shared libs",
5
+ "private": false,
6
+ "license": "UNLICENSED",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "type": "module",
11
+ "main": "dist/index.js",
12
+ "module": "dist/index.js",
13
+ "typings": "dist/index.d.ts",
14
+ "outputDir": "./dist",
15
+ "scripts": {
16
+ "build": "rimraf dist && yarn check:code && tsc",
17
+ "check:code": "yarn tsc && yarn run lint:fix && yarn test",
18
+ "lint": "eslint . --ext .js,.jsx,.ts,.tsx --cache",
19
+ "lint:fix": "yarn run lint --fix --max-warnings=0",
20
+ "postinstall": "husky",
21
+ "test": "vitest run",
22
+ "test:watch": "vitest"
23
+ },
24
+ "browserslist": [
25
+ ">0.2% in CZ",
26
+ "not dead",
27
+ "not op_mini all",
28
+ "not ie > 0",
29
+ "not ie_mob > 0"
30
+ ],
31
+ "dependencies": {
32
+ "react": "^17.0.2",
33
+ "react-dom": "^17.0.2"
34
+ },
35
+ "devDependencies": {
36
+ "@testing-library/react-hooks": "^8.0.1",
37
+ "@types/node": "22.17.0",
38
+ "@types/react": "^17.0.2",
39
+ "@types/react-dom": "^17.0.2",
40
+ "@vitejs/plugin-react": "^4.3.4",
41
+ "eslint": "^9.23.0",
42
+ "eslint-config-prettier": "^10.1.2",
43
+ "eslint-plugin-prettier": "^5.2.5",
44
+ "eslint-plugin-react": "^7.37.4",
45
+ "eslint-plugin-react-hooks": "^5.2.0",
46
+ "globals": "^16.0.0",
47
+ "husky": "^9.1.7",
48
+ "prettier": "^3.5.3",
49
+ "react-test-renderer": "17.0.2",
50
+ "rimraf": "3.0.2",
51
+ "typescript": "^5.8.2",
52
+ "typescript-eslint": "^8.29.0",
53
+ "vitest": "^3.1.2"
54
+ },
55
+ "peerDependencies": {
56
+ "react": ">=17",
57
+ "react-dom": ">=17"
58
+ },
59
+ "packageManager": "yarn@1.22.22"
60
+ }