@umituz/react-native-validation 1.3.2 → 1.4.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.
- package/README.md +0 -0
- package/package.json +1 -1
- package/src/domain/entities/ValidationResult.ts +0 -0
- package/src/index.ts +0 -2
- package/src/infrastructure/utils/image-validator.ts +1 -0
- package/src/infrastructure/utils/mime-type-validator.ts +0 -0
- package/src/infrastructure/utils/mime-types.constants.ts +1 -0
- package/src/infrastructure/utils/sanitization.ts +0 -0
- package/src/infrastructure/utils/validators.ts +0 -77
- package/LICENSE +0 -22
package/README.md
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
File without changes
|
package/src/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -21,83 +21,6 @@ export const validateEmail = (email: string): ValidationResult => {
|
|
|
21
21
|
return { isValid: true };
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
/**
|
|
25
|
-
* Validate password strength
|
|
26
|
-
* @param password - Password to validate
|
|
27
|
-
* @param minLength - Minimum password length (default: 8)
|
|
28
|
-
* @param requireUppercase - Require uppercase letter (default: true)
|
|
29
|
-
* @param requireLowercase - Require lowercase letter (default: true)
|
|
30
|
-
* @param requireNumber - Require number (default: true)
|
|
31
|
-
*/
|
|
32
|
-
export const validatePassword = (
|
|
33
|
-
password: string,
|
|
34
|
-
options?: {
|
|
35
|
-
minLength?: number;
|
|
36
|
-
requireUppercase?: boolean;
|
|
37
|
-
requireLowercase?: boolean;
|
|
38
|
-
requireNumber?: boolean;
|
|
39
|
-
}
|
|
40
|
-
): ValidationResult => {
|
|
41
|
-
const {
|
|
42
|
-
minLength = 8,
|
|
43
|
-
requireUppercase = true,
|
|
44
|
-
requireLowercase = true,
|
|
45
|
-
requireNumber = true,
|
|
46
|
-
} = options || {};
|
|
47
|
-
|
|
48
|
-
if (!password || password.trim() === '') {
|
|
49
|
-
return { isValid: false, error: 'Password is required' };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (password.length < minLength) {
|
|
53
|
-
return {
|
|
54
|
-
isValid: false,
|
|
55
|
-
error: `Password must be at least ${minLength} characters`,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (requireUppercase && !/[A-Z]/.test(password)) {
|
|
60
|
-
return {
|
|
61
|
-
isValid: false,
|
|
62
|
-
error: 'Password must contain at least one uppercase letter',
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (requireLowercase && !/[a-z]/.test(password)) {
|
|
67
|
-
return {
|
|
68
|
-
isValid: false,
|
|
69
|
-
error: 'Password must contain at least one lowercase letter',
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (requireNumber && !/[0-9]/.test(password)) {
|
|
74
|
-
return {
|
|
75
|
-
isValid: false,
|
|
76
|
-
error: 'Password must contain at least one number',
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return { isValid: true };
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Validate password confirmation
|
|
85
|
-
*/
|
|
86
|
-
export const validatePasswordConfirmation = (
|
|
87
|
-
password: string,
|
|
88
|
-
confirmPassword: string
|
|
89
|
-
): ValidationResult => {
|
|
90
|
-
if (!confirmPassword) {
|
|
91
|
-
return { isValid: false, error: 'Please confirm your password' };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (password !== confirmPassword) {
|
|
95
|
-
return { isValid: false, error: 'Passwords do not match' };
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return { isValid: true };
|
|
99
|
-
};
|
|
100
|
-
|
|
101
24
|
/**
|
|
102
25
|
* Validate required field
|
|
103
26
|
*/
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Ümit UZ
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|