@q2devel/q2-core 1.0.79 → 1.0.80
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.
|
@@ -8,5 +8,24 @@ export declare function handleSortChange(id: string): {
|
|
|
8
8
|
} | null;
|
|
9
9
|
export declare const generateCartToken: () => string;
|
|
10
10
|
export declare const formatPrice: (price: number, locale: string) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Validates password strength
|
|
13
|
+
* @param password - The password to validate
|
|
14
|
+
* @param minLength - Minimum password length (default: 8)
|
|
15
|
+
* @returns Object with isValid flag and error message
|
|
16
|
+
*/
|
|
17
|
+
export interface PasswordValidationResult {
|
|
18
|
+
isValid: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const validatePassword: (password: string, minLength?: number) => PasswordValidationResult;
|
|
22
|
+
/**
|
|
23
|
+
* Validates password strength for react-hook-form
|
|
24
|
+
* @param password - The password to validate
|
|
25
|
+
* @param minLength - Minimum password length (default: 8)
|
|
26
|
+
* @param t - Translation function
|
|
27
|
+
* @returns Error message or true if valid
|
|
28
|
+
*/
|
|
29
|
+
export declare const validatePasswordForForm: (password: string, minLength?: number, t?: (key: string) => string) => string | true;
|
|
11
30
|
export {};
|
|
12
31
|
//# sourceMappingURL=generalHelper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generalHelper.d.ts","sourceRoot":"","sources":["../../utils/generalHelper.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACX,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,kBAAkB,CAC9B,KAAK,CAAC,EAAE,KAAK,EACb,SAAS,CAAC,EAAE,KAAK,GAClB,MAAM,GAAG,IAAI,CAWf;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM;;;SAe1C;AAED,eAAO,MAAM,iBAAiB,QAAO,MAEpC,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,WAexD,CAAA"}
|
|
1
|
+
{"version":3,"file":"generalHelper.d.ts","sourceRoot":"","sources":["../../utils/generalHelper.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACX,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,kBAAkB,CAC9B,KAAK,CAAC,EAAE,KAAK,EACb,SAAS,CAAC,EAAE,KAAK,GAClB,MAAM,GAAG,IAAI,CAWf;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM;;;SAe1C;AAED,eAAO,MAAM,iBAAiB,QAAO,MAEpC,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,WAexD,CAAA;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,eAAO,MAAM,gBAAgB,GACzB,UAAU,MAAM,EAChB,YAAW,MAAU,KACtB,wBAgCF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAChC,UAAU,MAAM,EAChB,YAAW,MAAU,EACrB,IAAI,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,KAC5B,MAAM,GAAG,IAYX,CAAA"}
|
|
@@ -28,7 +28,7 @@ export const generateCartToken = () => {
|
|
|
28
28
|
};
|
|
29
29
|
export const formatPrice = (price, locale) => {
|
|
30
30
|
if (price === null || price === undefined) {
|
|
31
|
-
return locale === 'cs' ? '0,00
|
|
31
|
+
return locale === 'cs' ? '0,00 Kč' : '€0.00';
|
|
32
32
|
}
|
|
33
33
|
const roundedPrice = Number(price).toFixed(2);
|
|
34
34
|
const numericPrice = Number(roundedPrice);
|
|
@@ -39,3 +39,49 @@ export const formatPrice = (price, locale) => {
|
|
|
39
39
|
currency,
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
|
+
export const validatePassword = (password, minLength = 8) => {
|
|
43
|
+
if (!password) {
|
|
44
|
+
return {
|
|
45
|
+
isValid: false,
|
|
46
|
+
error: 'password-required',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (password.length < minLength) {
|
|
50
|
+
return {
|
|
51
|
+
isValid: false,
|
|
52
|
+
error: 'password-min-length',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (!/[A-Z]/.test(password)) {
|
|
56
|
+
return {
|
|
57
|
+
isValid: false,
|
|
58
|
+
error: 'password-uppercase-required',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (!/[0-9]/.test(password)) {
|
|
62
|
+
return {
|
|
63
|
+
isValid: false,
|
|
64
|
+
error: 'password-number-required',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
isValid: true,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Validates password strength for react-hook-form
|
|
73
|
+
* @param password - The password to validate
|
|
74
|
+
* @param minLength - Minimum password length (default: 8)
|
|
75
|
+
* @param t - Translation function
|
|
76
|
+
* @returns Error message or true if valid
|
|
77
|
+
*/
|
|
78
|
+
export const validatePasswordForForm = (password, minLength = 8, t) => {
|
|
79
|
+
const result = validatePassword(password, minLength);
|
|
80
|
+
if (result.isValid) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
if (t && result.error) {
|
|
84
|
+
return t(result.error);
|
|
85
|
+
}
|
|
86
|
+
return result.error || 'password-invalid';
|
|
87
|
+
};
|