create-gufran-expo-app 2.0.0 → 2.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.
- package/lib/createApp.js +7 -2
- package/package.json +1 -1
- package/template/App.tsx +118 -0
- package/template/ReactotronConfig.js +5 -0
- package/template/android/app/build.gradle +184 -0
- package/template/android/app/debug.keystore +0 -0
- package/template/android/app/google-services.json +29 -0
- package/template/android/app/proguard-rules.pro +14 -0
- package/template/android/app/src/debug/AndroidManifest.xml +7 -0
- package/template/android/app/src/debugOptimized/AndroidManifest.xml +7 -0
- package/template/android/app/src/main/AndroidManifest.xml +28 -0
- package/template/android/app/src/main/assets/fonts/Outfit-Bold.ttf +0 -0
- package/template/android/app/src/main/assets/fonts/Outfit-Light.ttf +0 -0
- package/template/android/app/src/main/assets/fonts/Outfit-Medium.ttf +0 -0
- package/template/android/app/src/main/assets/fonts/Outfit-Regular.ttf +0 -0
- package/template/android/app/src/main/assets/fonts/Outfit-SemiBold.ttf +0 -0
- package/template/android/app/src/main/java/com/club/yakka/MainActivity.kt +61 -0
- package/template/android/app/src/main/java/com/club/yakka/MainApplication.kt +60 -0
- package/template/android/app/src/main/res/drawable/ic_launcher_background.xml +6 -0
- package/template/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/template/android/app/src/main/res/drawable-hdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/drawable-mdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/drawable-xhdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/drawable-xxhdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/drawable-xxxhdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/template/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/values/colors.xml +6 -0
- package/template/android/app/src/main/res/values/strings.xml +5 -0
- package/template/android/app/src/main/res/values/styles.xml +14 -0
- package/template/android/app/src/main/res/values-night/colors.xml +1 -0
- package/template/android/build.gradle +33 -0
- package/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/template/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/template/android/gradle.properties +65 -0
- package/template/android/gradlew +251 -0
- package/template/android/gradlew.bat +94 -0
- package/template/android/settings.gradle +39 -0
- package/template/app.json +69 -0
- package/template/assets/adaptive-icon.png +0 -0
- package/template/assets/adaptive-icon1.png +0 -0
- package/template/assets/app_icon.png +0 -0
- package/template/assets/favicon.png +0 -0
- package/template/assets/icon.png +0 -0
- package/template/assets/splash-icon.png +0 -0
- package/template/babel-plugin-disable-font-scaling.js +41 -0
- package/template/babel.config.js +28 -0
- package/template/firebase.json +5 -0
- package/template/index.ts +24 -0
- package/template/ios/.xcode.env +11 -0
- package/template/ios/ClubYakka/AppDelegate.swift +74 -0
- package/template/ios/ClubYakka/ClubYakka-Bridging-Header.h +3 -0
- package/template/ios/ClubYakka/ClubYakka.entitlements +8 -0
- package/template/ios/ClubYakka/GoogleService-Info.plist +30 -0
- package/template/ios/ClubYakka/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png +0 -0
- package/template/ios/ClubYakka/Images.xcassets/AppIcon.appiconset/Contents.json +14 -0
- package/template/ios/ClubYakka/Images.xcassets/Contents.json +6 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenBackground.colorset/Contents.json +20 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenLegacy.imageset/Contents.json +23 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenLegacy.imageset/image.png +0 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenLegacy.imageset/image@2x.png +0 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenLegacy.imageset/image@3x.png +0 -0
- package/template/ios/ClubYakka/Info.plist +101 -0
- package/template/ios/ClubYakka/PrivacyInfo.xcprivacy +50 -0
- package/template/ios/ClubYakka/SplashScreen.storyboard +48 -0
- package/template/ios/ClubYakka/Supporting/Expo.plist +12 -0
- package/template/ios/ClubYakka.xcodeproj/project.pbxproj +669 -0
- package/template/ios/ClubYakka.xcodeproj/xcshareddata/xcschemes/ClubYakka.xcscheme +88 -0
- package/template/ios/ClubYakka.xcworkspace/contents.xcworkspacedata +10 -0
- package/template/ios/ClubYakka.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +5 -0
- package/template/ios/Podfile +84 -0
- package/template/ios/Podfile.lock +2698 -0
- package/template/ios/Podfile.properties.json +8 -0
- package/template/metro.config.js +17 -0
- package/template/package.json +70 -0
- package/template/patches/react-native-background-upload+6.6.0.patch +704 -0
- package/template/react-native.config.js +7 -0
- package/template/src/assets/fonts/Outfit-Bold.ttf +0 -0
- package/template/src/assets/fonts/Outfit-Light.ttf +0 -0
- package/template/src/assets/fonts/Outfit-Medium.ttf +0 -0
- package/template/src/assets/fonts/Outfit-Regular.ttf +0 -0
- package/template/src/assets/fonts/Outfit-SemiBold.ttf +0 -0
- package/template/src/assets/icons/BG.svg +33 -0
- package/template/src/assets/icons/Ic_Users.svg +6 -0
- package/template/src/assets/icons/arrow-left-white.svg +4 -0
- package/template/src/assets/icons/arrow-left.svg +4 -0
- package/template/src/assets/icons/bell.svg +4 -0
- package/template/src/assets/icons/bottomSheetIcone.svg +3 -0
- package/template/src/assets/icons/call.svg +4 -0
- package/template/src/assets/icons/camera.svg +0 -0
- package/template/src/assets/icons/chatAppleGreenBG.svg +22 -0
- package/template/src/assets/icons/check.svg +4 -0
- package/template/src/assets/icons/check_Radio.svg +4 -0
- package/template/src/assets/icons/chevron-right.svg +3 -0
- package/template/src/assets/icons/clubDefauldImage.png +0 -0
- package/template/src/assets/icons/curvBackgroundView.svg +3 -0
- package/template/src/assets/icons/defaultClub.png +0 -0
- package/template/src/assets/icons/email.svg +3 -0
- package/template/src/assets/icons/emptyUser.svg +5 -0
- package/template/src/assets/icons/eye-Hide.svg +8 -0
- package/template/src/assets/icons/eye.svg +4 -0
- package/template/src/assets/icons/gallery.svg +4 -0
- package/template/src/assets/icons/home.svg +4 -0
- package/template/src/assets/icons/ic_Calendar.svg +14 -0
- package/template/src/assets/icons/ic_Calendar_blue.svg +12 -0
- package/template/src/assets/icons/ic_Calendar_white.svg +12 -0
- package/template/src/assets/icons/ic_Chat.svg +14 -0
- package/template/src/assets/icons/ic_ChatAppleGreen.svg +21 -0
- package/template/src/assets/icons/ic_ChatAppleWhite.svg +21 -0
- package/template/src/assets/icons/ic_Download.svg +6 -0
- package/template/src/assets/icons/ic_Events.svg +6 -0
- package/template/src/assets/icons/ic_HeadCoachIcon.svg +3 -0
- package/template/src/assets/icons/ic_Membership.svg +10 -0
- package/template/src/assets/icons/ic_Notification.svg +6 -0
- package/template/src/assets/icons/ic_Raffles.svg +14 -0
- package/template/src/assets/icons/ic_Referral_Members.svg +12 -0
- package/template/src/assets/icons/ic_Shop.svg +13 -0
- package/template/src/assets/icons/ic_Teams.svg +8 -0
- package/template/src/assets/icons/ic_Volunteer.svg +9 -0
- package/template/src/assets/icons/ic_add.svg +3 -0
- package/template/src/assets/icons/ic_addCircle.svg +5 -0
- package/template/src/assets/icons/ic_chatSend.svg +4 -0
- package/template/src/assets/icons/ic_chat_blue_bg.svg +22 -0
- package/template/src/assets/icons/ic_clock_blue.svg +4 -0
- package/template/src/assets/icons/ic_delete.svg +8 -0
- package/template/src/assets/icons/ic_more.svg +5 -0
- package/template/src/assets/icons/ic_mute.svg +10 -0
- package/template/src/assets/icons/ic_pdf.svg +3 -0
- package/template/src/assets/icons/ic_pending_AppleGreen.svg +11 -0
- package/template/src/assets/icons/ic_right_appleGreen.svg +11 -0
- package/template/src/assets/icons/ic_unread_chat_blue_bg.svg +23 -0
- package/template/src/assets/icons/ic_volunteer_Member.svg +8 -0
- package/template/src/assets/icons/index.ts +144 -0
- package/template/src/assets/icons/location-blue.svg +4 -0
- package/template/src/assets/icons/location-white.svg +4 -0
- package/template/src/assets/icons/location.svg +4 -0
- package/template/src/assets/icons/lock.svg +5 -0
- package/template/src/assets/icons/log-out.svg +5 -0
- package/template/src/assets/icons/login_logo.svg +9 -0
- package/template/src/assets/icons/mail.svg +4 -0
- package/template/src/assets/icons/or_saprater.svg +5 -0
- package/template/src/assets/icons/password.svg +4 -0
- package/template/src/assets/icons/profile-appleGreen.svg +6 -0
- package/template/src/assets/icons/search.svg +3 -0
- package/template/src/assets/icons/settings.svg +4 -0
- package/template/src/assets/icons/success.svg +4 -0
- package/template/src/assets/icons/unCheck_Radio.svg +3 -0
- package/template/src/assets/icons/uncheck.svg +3 -0
- package/template/src/assets/icons/upload_Image.svg +6 -0
- package/template/src/assets/icons/upload_Image_Member.svg +6 -0
- package/template/src/assets/icons/user.svg +4 -0
- package/template/src/assets/icons/wifi.svg +1 -0
- package/template/src/assets/images/Splash.png +0 -0
- package/template/src/assets/images/SplashLogo.png +0 -0
- package/template/src/assets/images/background.png +0 -0
- package/template/src/assets/images/clubDefauldImage.png +0 -0
- package/template/src/assets/images/index.tsx +9 -0
- package/template/src/assets/index.ts +1 -0
- package/template/src/components/common/AddMemberModal.tsx +543 -0
- package/template/src/components/common/AppLoader.tsx +91 -0
- package/template/src/components/common/Button.tsx +173 -0
- package/template/src/components/common/ClubCard.tsx +248 -0
- package/template/src/components/common/Icon.tsx +93 -0
- package/template/src/components/common/IconAlt.tsx +65 -0
- package/template/src/components/common/IconButton.tsx +92 -0
- package/template/src/components/common/ImagePicker.tsx +451 -0
- package/template/src/components/common/LoadingSpinner.tsx +30 -0
- package/template/src/components/common/OTPInput.tsx +128 -0
- package/template/src/components/common/ReminderCalendar.tsx +129 -0
- package/template/src/components/common/ReminderCardItem.tsx +91 -0
- package/template/src/components/common/SafeAreaWrapper.tsx +27 -0
- package/template/src/components/common/SetReminderModal.tsx +308 -0
- package/template/src/components/common/SlowInternet.js +57 -0
- package/template/src/components/common/TeamCard.tsx +297 -0
- package/template/src/components/common/TextInput.tsx +227 -0
- package/template/src/components/common/ToastConfig.tsx +103 -0
- package/template/src/components/common/ToastManager.ts +86 -0
- package/template/src/components/common/UploadProgressModal.tsx +284 -0
- package/template/src/components/common/WrapperContainer.tsx +39 -0
- package/template/src/components/common/index.ts +19 -0
- package/template/src/constants/Constants.tsx +7 -0
- package/template/src/constants/Fonts.tsx +30 -0
- package/template/src/constants/index.ts +45 -0
- package/template/src/constants/strings.ts +211 -0
- package/template/src/constants/theme.ts +72 -0
- package/template/src/contexts/AuthContext.tsx +268 -0
- package/template/src/contexts/index.ts +2 -0
- package/template/src/hooks/index.ts +3 -0
- package/template/src/hooks/useImageUpload.ts +199 -0
- package/template/src/index.ts +8 -0
- package/template/src/navigation/AuthStack.tsx +67 -0
- package/template/src/navigation/MainStack.tsx +183 -0
- package/template/src/navigation/MiddleStack.tsx +35 -0
- package/template/src/navigation/RootNavigator.tsx +101 -0
- package/template/src/navigation/index.ts +5 -0
- package/template/src/navigation/navigationRef.ts +5 -0
- package/template/src/providers/QueryProvider.tsx +30 -0
- package/template/src/screens/DetailsScreen.tsx +271 -0
- package/template/src/screens/HomeScreen.tsx +736 -0
- package/template/src/screens/ProfileScreen.tsx +202 -0
- package/template/src/screens/SettingsScreen.tsx +253 -0
- package/template/src/screens/SportHubScreen.tsx +280 -0
- package/template/src/screens/auth/AddMamber.tsx +428 -0
- package/template/src/screens/auth/ForgotPasswordScreen.tsx +176 -0
- package/template/src/screens/auth/LoginScreen.tsx +286 -0
- package/template/src/screens/auth/OTPVerifyScreen.tsx +359 -0
- package/template/src/screens/auth/RegisterScreen.tsx +430 -0
- package/template/src/screens/auth/SuccessScreen.tsx +201 -0
- package/template/src/screens/auth/WalcomeScreen.tsx +274 -0
- package/template/src/screens/auth/index.ts +8 -0
- package/template/src/screens/chat/ChatScreen.tsx +1819 -0
- package/template/src/screens/chat/ChatThreadsScreen.tsx +360 -0
- package/template/src/screens/chat/ReportMessageScreen.tsx +238 -0
- package/template/src/screens/clubs/Announcements.tsx +426 -0
- package/template/src/screens/clubs/BuyRaffleTicketsScreen.tsx +568 -0
- package/template/src/screens/clubs/ClubDeteils.tsx +497 -0
- package/template/src/screens/clubs/JoinClub.tsx +841 -0
- package/template/src/screens/events/EventScreen.tsx +460 -0
- package/template/src/screens/index.ts +42 -0
- package/template/src/screens/raffles/MyReferralMembersScreen.tsx +758 -0
- package/template/src/screens/raffles/RaffleDetailsScreen.tsx +762 -0
- package/template/src/screens/raffles/RafflesScreen.tsx +495 -0
- package/template/src/screens/raffles/SetRaffleReminderScreen.tsx +390 -0
- package/template/src/screens/teams/JoinTeamScreen.tsx +464 -0
- package/template/src/screens/teams/MyTeamDetailsScreen.tsx +979 -0
- package/template/src/screens/teams/MyTeamScreen.tsx +568 -0
- package/template/src/screens/teams/PendingRequestsScreen.tsx +426 -0
- package/template/src/screens/volunteerOpportunities/SetReminderScreen.tsx +631 -0
- package/template/src/screens/volunteerOpportunities/VolunteerOpportunitiesDetailsScreen.tsx +1049 -0
- package/template/src/screens/volunteerOpportunities/VolunteerOpportunitiesScreen.tsx +608 -0
- package/template/src/services/api.ts +167 -0
- package/template/src/services/authService.ts +422 -0
- package/template/src/services/index.ts +5 -0
- package/template/src/services/mainServices.ts +1963 -0
- package/template/src/stores/authStore.ts +159 -0
- package/template/src/stores/index.ts +2 -0
- package/template/src/types/index.ts +85 -0
- package/template/src/types/navigation.ts +206 -0
- package/template/src/utils/AzureUploaderService.ts +371 -0
- package/template/src/utils/ClubSearchManager.ts +222 -0
- package/template/src/utils/NotificationManager.ts +503 -0
- package/template/src/utils/UploadDebugUtil.ts +107 -0
- package/template/src/utils/imagePicker.ts +321 -0
- package/template/src/utils/index.ts +111 -0
- package/template/src/utils/permissions.ts +277 -0
- package/template/src/utils/scaling.ts +14 -0
- package/template/src/utils/storage.ts +247 -0
- package/template/src/utils/usePermissions.ts +275 -0
- package/template/src/utils/validation.ts +340 -0
- package/template/tsconfig.json +50 -0
- package/template/types/svg.d.ts +6 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import ToastManager from '../components/common/ToastManager';
|
|
2
|
+
import { Strings } from '../constants/strings';
|
|
3
|
+
|
|
4
|
+
export interface ValidationRule {
|
|
5
|
+
required?: boolean;
|
|
6
|
+
minLength?: number;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
pattern?: RegExp;
|
|
9
|
+
custom?: (value: string) => boolean;
|
|
10
|
+
message?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ValidationResult {
|
|
14
|
+
isValid: boolean;
|
|
15
|
+
errors: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class ValidationClass {
|
|
19
|
+
private static instance: ValidationClass;
|
|
20
|
+
|
|
21
|
+
private constructor() {}
|
|
22
|
+
|
|
23
|
+
public static getInstance(): ValidationClass {
|
|
24
|
+
if (!ValidationClass.instance) {
|
|
25
|
+
ValidationClass.instance = new ValidationClass();
|
|
26
|
+
}
|
|
27
|
+
return ValidationClass.instance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Validate email format
|
|
32
|
+
*/
|
|
33
|
+
public validateEmail(email: string): boolean {
|
|
34
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
35
|
+
return emailRegex.test(email);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Validate password strength
|
|
40
|
+
*/
|
|
41
|
+
public validatePassword(password: string): boolean {
|
|
42
|
+
return password.length >= 8;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Validate required field
|
|
47
|
+
*/
|
|
48
|
+
public validateRequired(value: string): boolean {
|
|
49
|
+
return value.trim().length > 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Validate phone number
|
|
54
|
+
*/
|
|
55
|
+
public validatePhoneNumber(phoneNumber: string): boolean {
|
|
56
|
+
return phoneNumber.length >= 10;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Generic field validation with rules
|
|
61
|
+
*/
|
|
62
|
+
public validateField(value: string, rules: ValidationRule[]): ValidationResult {
|
|
63
|
+
const errors: string[] = [];
|
|
64
|
+
|
|
65
|
+
for (const rule of rules) {
|
|
66
|
+
if (rule.required && !this.validateRequired(value)) {
|
|
67
|
+
errors.push(rule.message || 'This field is required');
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (rule.minLength && value.length < rule.minLength) {
|
|
72
|
+
errors.push(rule.message || `Minimum length is ${rule.minLength}`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (rule.maxLength && value.length > rule.maxLength) {
|
|
77
|
+
errors.push(rule.message || `Maximum length is ${rule.maxLength}`);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (rule.pattern && !rule.pattern.test(value)) {
|
|
82
|
+
errors.push(rule.message || 'Invalid format');
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (rule.custom && !rule.custom(value)) {
|
|
87
|
+
errors.push(rule.message || 'Invalid value');
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
isValid: errors.length === 0,
|
|
94
|
+
errors
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Validate login form
|
|
100
|
+
*/
|
|
101
|
+
public validateLoginForm(email: string, password: string): ValidationResult {
|
|
102
|
+
const errors: string[] = [];
|
|
103
|
+
|
|
104
|
+
if (!this.validateRequired(email)) {
|
|
105
|
+
errors.push(Strings.AUTH.EMAIL_REQUIRED);
|
|
106
|
+
} else if (!this.validateEmail(email)) {
|
|
107
|
+
errors.push(Strings.AUTH.VALID_EMAIL_ADDRESS_REQUIRED);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!this.validateRequired(password)) {
|
|
111
|
+
errors.push('Password is required');
|
|
112
|
+
} else if (!this.validatePassword(password)) {
|
|
113
|
+
errors.push('Password must be at least 8 characters long');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
isValid: errors.length === 0,
|
|
118
|
+
errors
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Validate forgot password form
|
|
124
|
+
*/
|
|
125
|
+
public validateForgotPasswordForm(email: string): ValidationResult {
|
|
126
|
+
const errors: string[] = [];
|
|
127
|
+
|
|
128
|
+
if (!this.validateRequired(email)) {
|
|
129
|
+
errors.push(Strings.AUTH.EMAIL_REQUIRED);
|
|
130
|
+
} else if (!this.validateEmail(email)) {
|
|
131
|
+
errors.push(Strings.AUTH.VALID_EMAIL_ADDRESS_REQUIRED);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
isValid: errors.length === 0,
|
|
136
|
+
errors
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Validate registration form
|
|
142
|
+
*/
|
|
143
|
+
public validateRegistrationForm(data: {
|
|
144
|
+
email: string;
|
|
145
|
+
password: string;
|
|
146
|
+
confirmPassword: string;
|
|
147
|
+
name?: string;
|
|
148
|
+
phone?: string;
|
|
149
|
+
}): ValidationResult {
|
|
150
|
+
const errors: string[] = [];
|
|
151
|
+
|
|
152
|
+
// Email validation
|
|
153
|
+
if (!this.validateRequired(data.email)) {
|
|
154
|
+
errors.push(Strings.AUTH.EMAIL_REQUIRED);
|
|
155
|
+
} else if (!this.validateEmail(data.email)) {
|
|
156
|
+
errors.push(Strings.AUTH.VALID_EMAIL_ADDRESS_REQUIRED);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Password validation
|
|
160
|
+
if (!this.validateRequired(data.password)) {
|
|
161
|
+
errors.push('Password is required');
|
|
162
|
+
} else if (!this.validatePassword(data.password)) {
|
|
163
|
+
errors.push('Password must be at least 8 characters long');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Confirm password validation
|
|
167
|
+
if (!this.validateRequired(data.confirmPassword)) {
|
|
168
|
+
errors.push('Please confirm your password');
|
|
169
|
+
} else if (data.password !== data.confirmPassword) {
|
|
170
|
+
errors.push('Passwords do not match');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Name validation (if provided)
|
|
174
|
+
if (data.name && !this.validateRequired(data.name)) {
|
|
175
|
+
errors.push('Name is required');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Phone validation (if provided)
|
|
179
|
+
if (data.phone && !this.validatePhoneNumber(data.phone)) {
|
|
180
|
+
errors.push('Please enter a valid phone number');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
isValid: errors.length === 0,
|
|
185
|
+
errors
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Show validation errors using ToastManager
|
|
191
|
+
*/
|
|
192
|
+
public showValidationErrors(errors: string[]): void {
|
|
193
|
+
if (errors.length > 0) {
|
|
194
|
+
ToastManager.error(errors[0]);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Validate and show errors if validation fails
|
|
200
|
+
*/
|
|
201
|
+
public validateAndShowErrors(value: string, rules: ValidationRule[]): boolean {
|
|
202
|
+
const result = this.validateField(value, rules);
|
|
203
|
+
if (!result.isValid) {
|
|
204
|
+
this.showValidationErrors(result.errors);
|
|
205
|
+
}
|
|
206
|
+
return result.isValid;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Validate login form and show errors
|
|
211
|
+
*/
|
|
212
|
+
public validateLoginFormAndShowErrors(email: string, password: string): boolean {
|
|
213
|
+
const result = this.validateLoginForm(email, password);
|
|
214
|
+
if (!result.isValid) {
|
|
215
|
+
this.showValidationErrors(result.errors);
|
|
216
|
+
}
|
|
217
|
+
return result.isValid;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Validate forgot password form and show errors
|
|
222
|
+
*/
|
|
223
|
+
public validateForgotPasswordFormAndShowErrors(email: string): boolean {
|
|
224
|
+
const result = this.validateForgotPasswordForm(email);
|
|
225
|
+
if (!result.isValid) {
|
|
226
|
+
this.showValidationErrors(result.errors);
|
|
227
|
+
}
|
|
228
|
+
return result.isValid;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Validate registration form and show errors
|
|
233
|
+
*/
|
|
234
|
+
public validateRegistrationFormAndShowErrors(data: {
|
|
235
|
+
email: string;
|
|
236
|
+
password: string;
|
|
237
|
+
confirmPassword: string;
|
|
238
|
+
name?: string;
|
|
239
|
+
phone?: string;
|
|
240
|
+
}): boolean {
|
|
241
|
+
const result = this.validateRegistrationForm(data);
|
|
242
|
+
if (!result.isValid) {
|
|
243
|
+
this.showValidationErrors(result.errors);
|
|
244
|
+
}
|
|
245
|
+
return result.isValid;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Validate member name
|
|
250
|
+
*/
|
|
251
|
+
public validateMemberName(name: string): boolean {
|
|
252
|
+
const trimmedName = name.trim();
|
|
253
|
+
return trimmedName.length >= 2 && trimmedName.length <= 50 && /^[a-zA-Z\s]+$/.test(trimmedName);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Validate date of birth
|
|
258
|
+
*/
|
|
259
|
+
public validateDateOfBirth(dateOfBirth: Date): boolean {
|
|
260
|
+
const today = new Date();
|
|
261
|
+
const minDate = new Date(today.getFullYear() - 120, today.getMonth(), today.getDate()); // Max age 120
|
|
262
|
+
const maxDate = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate()); // Min age 1
|
|
263
|
+
|
|
264
|
+
return dateOfBirth >= minDate && dateOfBirth <= maxDate;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Validate relationship type
|
|
269
|
+
*/
|
|
270
|
+
public validateRelationshipType(relationshipType: string): boolean {
|
|
271
|
+
const validRelationships = [
|
|
272
|
+
'Father', 'Mother', 'Son', 'Daughter', 'Brother', 'Sister',
|
|
273
|
+
'Husband', 'Wife', 'Grandfather', 'Grandmother', 'Grandson',
|
|
274
|
+
'Granddaughter', 'Uncle', 'Aunt', 'Nephew', 'Niece', 'Cousin',
|
|
275
|
+
'Father-in-law', 'Mother-in-law', 'Son-in-law', 'Daughter-in-law',
|
|
276
|
+
'Brother-in-law', 'Sister-in-law', 'Other'
|
|
277
|
+
];
|
|
278
|
+
|
|
279
|
+
return validRelationships.includes(relationshipType.trim());
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Validate member form
|
|
284
|
+
*/
|
|
285
|
+
public validateMemberForm(data: {
|
|
286
|
+
name: string;
|
|
287
|
+
dateOfBirth: Date;
|
|
288
|
+
relationshipType: string;
|
|
289
|
+
}): ValidationResult {
|
|
290
|
+
const errors: string[] = [];
|
|
291
|
+
|
|
292
|
+
// Name validation
|
|
293
|
+
if (!this.validateRequired(data.name)) {
|
|
294
|
+
errors.push('Member name is required');
|
|
295
|
+
} else if (!this.validateMemberName(data.name)) {
|
|
296
|
+
errors.push('Name must be 2-50 characters long and contain only letters and spaces');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Date of birth validation
|
|
300
|
+
if (!this.validateDateOfBirth(data.dateOfBirth)) {
|
|
301
|
+
errors.push('Please select a valid date of birth (age must be between 1 and 120 years)');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Relationship type validation
|
|
305
|
+
if (!this.validateRequired(data.relationshipType)) {
|
|
306
|
+
errors.push('Relationship type is required');
|
|
307
|
+
} else if (!this.validateRelationshipType(data.relationshipType)) {
|
|
308
|
+
errors.push('Please select a valid relationship type');
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
isValid: errors.length === 0,
|
|
313
|
+
errors
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Validate member form and show errors
|
|
319
|
+
*/
|
|
320
|
+
public validateMemberFormAndShowErrors(data: {
|
|
321
|
+
name: string;
|
|
322
|
+
dateOfBirth: Date;
|
|
323
|
+
relationshipType: string;
|
|
324
|
+
}): boolean {
|
|
325
|
+
const result = this.validateMemberForm(data);
|
|
326
|
+
if (!result.isValid) {
|
|
327
|
+
this.showValidationErrors(result.errors);
|
|
328
|
+
}
|
|
329
|
+
return result.isValid;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Export singleton instance
|
|
334
|
+
export const Validation = ValidationClass.getInstance();
|
|
335
|
+
|
|
336
|
+
// Export individual validation functions for backward compatibility
|
|
337
|
+
export const validateEmail = (email: string): boolean => Validation.validateEmail(email);
|
|
338
|
+
export const validatePassword = (password: string): boolean => Validation.validatePassword(password);
|
|
339
|
+
export const validateRequired = (value: string): boolean => Validation.validateRequired(value);
|
|
340
|
+
export const validatePhoneNumber = (phoneNumber: string): boolean => Validation.validatePhoneNumber(phoneNumber);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "expo/tsconfig.base",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"paths": {
|
|
6
|
+
"@navigation": [
|
|
7
|
+
"src/types/navigation"
|
|
8
|
+
],
|
|
9
|
+
"@assets": [
|
|
10
|
+
"src/assets"
|
|
11
|
+
],
|
|
12
|
+
"@assets/*": [
|
|
13
|
+
"src/assets/*"
|
|
14
|
+
],
|
|
15
|
+
"@constants": [
|
|
16
|
+
"src/constants"
|
|
17
|
+
],
|
|
18
|
+
"@constants/*": [
|
|
19
|
+
"src/constants/*"
|
|
20
|
+
],
|
|
21
|
+
"@utils": [
|
|
22
|
+
"src/utils"
|
|
23
|
+
],
|
|
24
|
+
"@utils/*": [
|
|
25
|
+
"src/utils/*"
|
|
26
|
+
],
|
|
27
|
+
"@components": [
|
|
28
|
+
"src/components"
|
|
29
|
+
],
|
|
30
|
+
"@components/*": [
|
|
31
|
+
"src/components/*"
|
|
32
|
+
],
|
|
33
|
+
"@stores": [
|
|
34
|
+
"src/stores"
|
|
35
|
+
],
|
|
36
|
+
"@stores/*": [
|
|
37
|
+
"src/stores/*"
|
|
38
|
+
],
|
|
39
|
+
"@services": [
|
|
40
|
+
"src/services"
|
|
41
|
+
],
|
|
42
|
+
"@services/*": [
|
|
43
|
+
"src/services/*"
|
|
44
|
+
],
|
|
45
|
+
"@config/*": [
|
|
46
|
+
"src/config/*"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|