@towsila/expo-ui-library 1.9.0 → 2.0.0
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/package.json +1 -1
- package/src/components/screens/AddReportScreen.tsx +4 -2
- package/src/components/screens/VerificationCodeScreen.tsx +4 -2
- package/src/components/screens/forgotPasswordScreen.tsx +3 -1
- package/src/components/screens/loginScreen.tsx +4 -2
- package/src/components/screens/onBoarding.tsx +10 -1
- package/src/components/screens/resetPassword.tsx +5 -3
- package/src/components/screens/signUpScreen.tsx +4 -1
- package/src/components/ui/PageTopBar.tsx +2 -2
- package/src/components/ui/sharpDynamicForm.tsx +3 -1
- package/src/components/ui/sharpInput.tsx +59 -78
- package/src/utils/inputValidator/customValidator.ts +9 -10
package/package.json
CHANGED
|
@@ -20,6 +20,7 @@ interface ReportProps {
|
|
|
20
20
|
error?: string;
|
|
21
21
|
textLabel?: string;
|
|
22
22
|
selectLabel?:string;
|
|
23
|
+
t?: (key: string) => string;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export default function AddReport({
|
|
@@ -33,6 +34,7 @@ export default function AddReport({
|
|
|
33
34
|
error,
|
|
34
35
|
textLabel,
|
|
35
36
|
selectLabel,
|
|
37
|
+
t,
|
|
36
38
|
}: ReportProps) {
|
|
37
39
|
const form = useSubmitReport({ onSubmit });
|
|
38
40
|
const { colors } = useAppTheme();
|
|
@@ -90,7 +92,7 @@ export default function AddReport({
|
|
|
90
92
|
);
|
|
91
93
|
})}
|
|
92
94
|
</View>
|
|
93
|
-
{form.errors.target && <ErrorMessage message={form.errors.target} />}
|
|
95
|
+
{form.errors.target && <ErrorMessage message={t?.(form.errors.target) || form.errors.target} />}
|
|
94
96
|
</View>
|
|
95
97
|
|
|
96
98
|
{/* Details textarea */}
|
|
@@ -109,7 +111,7 @@ export default function AddReport({
|
|
|
109
111
|
numberOfLines={4}
|
|
110
112
|
textAlignVertical="top"
|
|
111
113
|
height={100}
|
|
112
|
-
error={form.errors.reason}
|
|
114
|
+
error={form.errors.reason ? t?.(form.errors.reason) : ""}
|
|
113
115
|
onClearError={() => form.clearError("reason")}
|
|
114
116
|
bgColor={colors.background.main}
|
|
115
117
|
/>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
import { Text, TouchableOpacity } from "react-native";
|
|
2
|
+
import { I18nManager, Text, TouchableOpacity } from "react-native";
|
|
3
3
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
4
|
import { textSize, Fonts} from "../../tokens/typography";
|
|
5
5
|
import TemplateSubPage from "../reusable/templateSubPage";
|
|
@@ -17,6 +17,7 @@ interface VerificationCodeScreenProps {
|
|
|
17
17
|
resendBtn?:string;
|
|
18
18
|
onBack: ()=>void;
|
|
19
19
|
loading?: boolean;
|
|
20
|
+
unit?: string;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export default function VerificationCodeScreen({
|
|
@@ -30,6 +31,7 @@ export default function VerificationCodeScreen({
|
|
|
30
31
|
onBack,
|
|
31
32
|
loading,
|
|
32
33
|
resendBtn="Resend Code",
|
|
34
|
+
unit,
|
|
33
35
|
}: VerificationCodeScreenProps) {
|
|
34
36
|
const { colors } = useAppTheme();
|
|
35
37
|
const [code, setCode] = useState("");
|
|
@@ -52,7 +54,7 @@ export default function VerificationCodeScreen({
|
|
|
52
54
|
<SharpOtpInput length={4} onChange={setCode} />
|
|
53
55
|
{count !== 0 ? (
|
|
54
56
|
<Text style={{ textAlign: "center", color: colors.text.placeholder, fontSize: textSize.xs, fontFamily: Fonts.montserrat.regular}}>
|
|
55
|
-
{resendText}: {count}
|
|
57
|
+
{resendText}: {count} {unit}
|
|
56
58
|
</Text>
|
|
57
59
|
) : (
|
|
58
60
|
<TouchableOpacity onPress={handleResend}>
|
|
@@ -15,6 +15,7 @@ interface ForgetPwScreenProps {
|
|
|
15
15
|
inputLabel?:string;
|
|
16
16
|
inputPlaceholder: string;
|
|
17
17
|
onBack: ()=>void;
|
|
18
|
+
t?: (key:string) => string;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export default function ForgotPwScreen({
|
|
@@ -26,6 +27,7 @@ export default function ForgotPwScreen({
|
|
|
26
27
|
inputLabel,
|
|
27
28
|
inputPlaceholder,
|
|
28
29
|
onBack,
|
|
30
|
+
t,
|
|
29
31
|
}: ForgetPwScreenProps) {
|
|
30
32
|
|
|
31
33
|
const form = useForgotPasswordForm({onSubmit});
|
|
@@ -47,7 +49,7 @@ export default function ForgotPwScreen({
|
|
|
47
49
|
label={inputLabel}
|
|
48
50
|
keyboardType="email-address"
|
|
49
51
|
iconLeft={(color) => <Email width={18} height={18} color={color}/>}
|
|
50
|
-
error={form.errors.input}
|
|
52
|
+
error={form.errors.input ? t?.(form.errors.input) : ""}
|
|
51
53
|
autoCapitalize="none"
|
|
52
54
|
autoComplete="email"
|
|
53
55
|
textContentType="emailAddress"
|
|
@@ -30,6 +30,7 @@ interface LoginScreenProps {
|
|
|
30
30
|
noAccountLabel?: string;
|
|
31
31
|
signUpLabel?: string;
|
|
32
32
|
googleLabel?: string;
|
|
33
|
+
t?: (key: string) => string;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export default function LoginScreen({
|
|
@@ -50,6 +51,7 @@ export default function LoginScreen({
|
|
|
50
51
|
noAccountLabel = "Don't have an account?",
|
|
51
52
|
signUpLabel = "Create one",
|
|
52
53
|
googleLabel,
|
|
54
|
+
t,
|
|
53
55
|
}: LoginScreenProps) {
|
|
54
56
|
const { colors, isDark } = useAppTheme();
|
|
55
57
|
const form = useLoginForm({ onLogin });
|
|
@@ -67,7 +69,7 @@ export default function LoginScreen({
|
|
|
67
69
|
onChangeText={(text)=>form.setValue("email", text)}
|
|
68
70
|
placeholder={emailPlaceholder}
|
|
69
71
|
keyboardType="email-address"
|
|
70
|
-
error={form.errors.email}
|
|
72
|
+
error={form.errors.email ? t?.(form.errors.email) : ""}
|
|
71
73
|
autoCapitalize="none"
|
|
72
74
|
autoComplete="email"
|
|
73
75
|
textContentType="emailAddress"
|
|
@@ -88,7 +90,7 @@ export default function LoginScreen({
|
|
|
88
90
|
secureTextEntry={!form.showPassword}
|
|
89
91
|
textContentType="password"
|
|
90
92
|
returnKeyType="done"
|
|
91
|
-
error={form.errors.password}
|
|
93
|
+
error={form.errors.password ? t?.(form.errors.password) : ""}
|
|
92
94
|
onClearError={() => form.clearError("password")}
|
|
93
95
|
iconLeft={(color)=><LockClosed width={18} height={18} color={color}/>}
|
|
94
96
|
/>
|
|
@@ -4,6 +4,7 @@ import { useAppTheme } from "../../context/ThemeContext";
|
|
|
4
4
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
5
5
|
import {Arrow} from "@towsila/icons";
|
|
6
6
|
import SharpButton from "../ui/sharpButton";
|
|
7
|
+
import { I18nManager } from "react-native";
|
|
7
8
|
|
|
8
9
|
interface OnBoardingProps {
|
|
9
10
|
onSkip: () => void;
|
|
@@ -48,7 +49,15 @@ export default function OnBoarding({
|
|
|
48
49
|
>
|
|
49
50
|
{skipLabel}
|
|
50
51
|
</Text>
|
|
51
|
-
|
|
52
|
+
<Arrow
|
|
53
|
+
width={20}
|
|
54
|
+
height={20}
|
|
55
|
+
color={colors.text.primary}
|
|
56
|
+
style={[
|
|
57
|
+
styles.skipIcon,
|
|
58
|
+
I18nManager.isRTL && { transform: [{ scaleX: -1 }] },
|
|
59
|
+
]}
|
|
60
|
+
/>
|
|
52
61
|
</TouchableOpacity>
|
|
53
62
|
</View>
|
|
54
63
|
|
|
@@ -21,6 +21,7 @@ interface ResetPasswordScreenProps {
|
|
|
21
21
|
includeOldPassword?: boolean;
|
|
22
22
|
onReset: (password: string, oldPassword?: string) => Promise<void>;
|
|
23
23
|
errorMessage?: string;
|
|
24
|
+
t?: (key: string) => string;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export default function ResetPasswordScreen({
|
|
@@ -39,6 +40,7 @@ export default function ResetPasswordScreen({
|
|
|
39
40
|
includeOldPassword = false,
|
|
40
41
|
onReset,
|
|
41
42
|
errorMessage,
|
|
43
|
+
t,
|
|
42
44
|
}: ResetPasswordScreenProps) {
|
|
43
45
|
const form = useResetPasswordForm({ onReset , includeOldPassword});
|
|
44
46
|
|
|
@@ -67,7 +69,7 @@ export default function ResetPasswordScreen({
|
|
|
67
69
|
secureTextEntry={!form.showOldPassword}
|
|
68
70
|
textContentType="password"
|
|
69
71
|
returnKeyType="next"
|
|
70
|
-
error={form.errors.oldPassword}
|
|
72
|
+
error={form.errors.oldPassword ? t?.(form.errors.oldPassword) : ""}
|
|
71
73
|
onClearError={() => form.clearError("oldPassword")}
|
|
72
74
|
/>
|
|
73
75
|
)}
|
|
@@ -82,7 +84,7 @@ export default function ResetPasswordScreen({
|
|
|
82
84
|
secureTextEntry={!form.showPassword}
|
|
83
85
|
textContentType="password"
|
|
84
86
|
returnKeyType="next"
|
|
85
|
-
error={form.errors.password}
|
|
87
|
+
error={form.errors.password ? t?.(form.errors.password) : ""}
|
|
86
88
|
onClearError={() => form.clearError("password")}
|
|
87
89
|
/>
|
|
88
90
|
{cardItems && (
|
|
@@ -104,7 +106,7 @@ export default function ResetPasswordScreen({
|
|
|
104
106
|
secureTextEntry={!form.showConfirmPassword}
|
|
105
107
|
textContentType="password"
|
|
106
108
|
returnKeyType="done"
|
|
107
|
-
error={form.errors.confirmPassword}
|
|
109
|
+
error={form.errors.confirmPassword ? t?.(form.errors.confirmPassword) : ""}
|
|
108
110
|
onClearError={() => form.clearError("confirmPassword")}
|
|
109
111
|
/>
|
|
110
112
|
</TemplateSubPage>
|
|
@@ -28,6 +28,7 @@ generalTerms: string[];
|
|
|
28
28
|
dialogTitle:string;
|
|
29
29
|
dialogDescription: string;
|
|
30
30
|
dialogButton: string;
|
|
31
|
+
t?: (key: string) => string;
|
|
31
32
|
}
|
|
32
33
|
export default function SignupPage({
|
|
33
34
|
title,
|
|
@@ -46,7 +47,8 @@ export default function SignupPage({
|
|
|
46
47
|
generalTerms,
|
|
47
48
|
dialogTitle,
|
|
48
49
|
dialogDescription,
|
|
49
|
-
dialogButton
|
|
50
|
+
dialogButton,
|
|
51
|
+
t,
|
|
50
52
|
}: SignupProps) {
|
|
51
53
|
const [showTerms, setShowTerms] = useState(true);
|
|
52
54
|
const {colors} = useAppTheme();
|
|
@@ -74,6 +76,7 @@ export default function SignupPage({
|
|
|
74
76
|
nextLabel={nextLabel}
|
|
75
77
|
backLabel={backLabel}
|
|
76
78
|
setErrors={setErrors}
|
|
79
|
+
translator={t}
|
|
77
80
|
/>
|
|
78
81
|
{isLastStep && (
|
|
79
82
|
<SharpButton
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
2
2
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
3
|
-
import { Text, TouchableOpacity, View } from "react-native";
|
|
3
|
+
import { I18nManager, Text, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import {ArrowBack} from "@towsila/icons";
|
|
5
5
|
|
|
6
6
|
interface PageProps{
|
|
@@ -18,7 +18,7 @@ export default function PageTopBar({title, description, onBack}:PageProps){
|
|
|
18
18
|
flexDirection: "row",
|
|
19
19
|
alignItems: "center", marginBottom: 10 }}>
|
|
20
20
|
<TouchableOpacity onPress={onBack}>
|
|
21
|
-
<ArrowBack width={24} height={24} color={colors.text.primary}/>
|
|
21
|
+
<ArrowBack width={24} height={24} color={colors.text.primary} style={[I18nManager.isRTL && { transform: [{ scaleX: -1 }] },]}/>
|
|
22
22
|
</TouchableOpacity>
|
|
23
23
|
<Text style={{ flex: 1, textAlign: "center", color: colors.text.primary, fontSize: textSize.xxl, fontFamily: Fonts.montserrat.bold }}>
|
|
24
24
|
{title}
|
|
@@ -16,6 +16,7 @@ interface Props {
|
|
|
16
16
|
onStepChange?: (step: number, total: number) => void;
|
|
17
17
|
nextLabel?: string;
|
|
18
18
|
backLabel?: string;
|
|
19
|
+
translator?: (key: string) => string;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
function splitIntoSteps(fields: Field[]): Field[][] {
|
|
@@ -49,6 +50,7 @@ export const SharpDynamicForm: React.FC<Props> = ({
|
|
|
49
50
|
onStepChange,
|
|
50
51
|
nextLabel,
|
|
51
52
|
backLabel,
|
|
53
|
+
translator,
|
|
52
54
|
}) => {
|
|
53
55
|
const [showPasswordField, setShowPasswordField] = useState<Record<string, boolean>>({});
|
|
54
56
|
const [currentStep, setCurrentStep] = useState(0);
|
|
@@ -96,7 +98,7 @@ export const SharpDynamicForm: React.FC<Props> = ({
|
|
|
96
98
|
}
|
|
97
99
|
secureTextEntry={field.secureTextEntry && !showPasswordField[field.name]}
|
|
98
100
|
returnKeyType="next"
|
|
99
|
-
error={errors[field.name]}
|
|
101
|
+
error={errors[field.name] ? translator?.(errors[field.name]) : ""}
|
|
100
102
|
onClearError={() => clearError(field.name)}
|
|
101
103
|
label={field.label}
|
|
102
104
|
/>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import { Text, TextInput, TextInputProps, View, StyleSheet, TouchableOpacity } from "react-native";
|
|
2
|
+
import { Text, TextInput, TextInputProps, View, StyleSheet, TouchableOpacity, I18nManager } from "react-native";
|
|
3
3
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
4
|
import { textSize, Fonts } from "../../tokens/typography";
|
|
5
5
|
import ErrorMessage from "./error";
|
|
6
6
|
import SharpContainer from "./sharpContainer";
|
|
7
|
+
|
|
7
8
|
interface InputProps extends TextInputProps {
|
|
8
9
|
value: string;
|
|
9
10
|
onChangeText: (text: string) => void;
|
|
@@ -44,76 +45,61 @@ export default function SharpInput({
|
|
|
44
45
|
return colors.semantic.border; // default border color
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
return (
|
|
48
|
-
<View style={{ marginBottom: 4 }}>
|
|
49
|
-
{label && (
|
|
50
|
-
<Text
|
|
51
|
-
style={{
|
|
52
|
-
color: colors.text.primary,
|
|
53
|
-
fontSize: textSize.xs,
|
|
54
|
-
fontFamily: Fonts.montserrat.semiBold,
|
|
55
|
-
marginBottom: 6,
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
{label}
|
|
59
|
-
</Text>
|
|
60
|
-
)}
|
|
61
48
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<View style={styles.inputWrapper}>
|
|
70
|
-
{iconLeft && (
|
|
71
|
-
<View style={styles.iconLeft}>
|
|
72
|
-
{iconLeft(getBorderColor())}
|
|
73
|
-
</View>
|
|
74
|
-
)}
|
|
75
|
-
{prefix && (
|
|
76
|
-
<View style={styles.prefix}>
|
|
77
|
-
{prefix}
|
|
78
|
-
</View>
|
|
79
|
-
)}
|
|
49
|
+
return (
|
|
50
|
+
<View style={{ marginBottom: 4 }}>
|
|
51
|
+
{label && (
|
|
52
|
+
<Text style={{ color: colors.text.primary, fontSize: textSize.xs, fontFamily: Fonts.montserrat.semiBold, marginBottom: 6 }}>
|
|
53
|
+
{label}
|
|
54
|
+
</Text>
|
|
55
|
+
)}
|
|
80
56
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
placeholderTextColor={colors.text.secondary}
|
|
89
|
-
onFocus={() => {
|
|
90
|
-
setFocused(true);
|
|
91
|
-
if (error) onClearError?.();
|
|
92
|
-
}}
|
|
93
|
-
onBlur={() => setFocused(false)}
|
|
94
|
-
style={[
|
|
95
|
-
styles.input,
|
|
96
|
-
{
|
|
97
|
-
color: colors.text.primary,
|
|
98
|
-
paddingLeft: iconLeft ? 42 : 16,
|
|
99
|
-
paddingRight: iconRight ? 42 : 16,
|
|
100
|
-
backgroundColor: "transparent", // let SharpContainer handle background
|
|
101
|
-
},
|
|
102
|
-
]}
|
|
103
|
-
{...rest}
|
|
104
|
-
/>
|
|
57
|
+
<SharpContainer height={height} bgColor={bgColor ?? colors.background.main} borderColor={getBorderColor()}>
|
|
58
|
+
<View style={styles.inputWrapper}>
|
|
59
|
+
{iconLeft && (
|
|
60
|
+
<View style={styles.iconSlot}>
|
|
61
|
+
{iconLeft(getBorderColor())}
|
|
62
|
+
</View>
|
|
63
|
+
)}
|
|
105
64
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
65
|
+
{prefix && (
|
|
66
|
+
<View style={styles.prefix}>
|
|
67
|
+
{prefix}
|
|
68
|
+
</View>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
<TextInput
|
|
72
|
+
value={value}
|
|
73
|
+
onChangeText={(text) => {
|
|
74
|
+
onChangeText(text);
|
|
75
|
+
if (error) onClearError?.();
|
|
76
|
+
}}
|
|
77
|
+
placeholder={placeholder}
|
|
78
|
+
placeholderTextColor={colors.text.secondary}
|
|
79
|
+
onFocus={() => { setFocused(true); if (error) onClearError?.(); }}
|
|
80
|
+
onBlur={() => setFocused(false)}
|
|
81
|
+
style={[
|
|
82
|
+
styles.input,
|
|
83
|
+
{
|
|
84
|
+
color: colors.text.primary,
|
|
85
|
+
backgroundColor: "transparent",
|
|
86
|
+
textAlign: I18nManager.isRTL ? "right" : "left",
|
|
87
|
+
},
|
|
88
|
+
]}
|
|
89
|
+
{...rest}
|
|
90
|
+
/>
|
|
113
91
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
92
|
+
{iconRight && (
|
|
93
|
+
<TouchableOpacity onPress={onPressIconRight} style={styles.iconSlot}>
|
|
94
|
+
{iconRight(colors.semantic.border)}
|
|
95
|
+
</TouchableOpacity>
|
|
96
|
+
)}
|
|
97
|
+
</View>
|
|
98
|
+
</SharpContainer>
|
|
99
|
+
|
|
100
|
+
{error && <ErrorMessage message={error} />}
|
|
101
|
+
</View>
|
|
102
|
+
);
|
|
117
103
|
}
|
|
118
104
|
|
|
119
105
|
const styles = StyleSheet.create({
|
|
@@ -121,17 +107,11 @@ const styles = StyleSheet.create({
|
|
|
121
107
|
flex: 1,
|
|
122
108
|
flexDirection: "row",
|
|
123
109
|
alignItems: "center",
|
|
124
|
-
paddingHorizontal: 4, // small inner padding
|
|
125
|
-
},
|
|
126
|
-
iconLeft: {
|
|
127
|
-
position: "absolute",
|
|
128
|
-
left: 14,
|
|
129
|
-
zIndex: 1,
|
|
130
110
|
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
111
|
+
iconSlot: {
|
|
112
|
+
paddingHorizontal: 12,
|
|
113
|
+
justifyContent: "center",
|
|
114
|
+
alignItems: "center",
|
|
135
115
|
},
|
|
136
116
|
input: {
|
|
137
117
|
flex: 1,
|
|
@@ -143,6 +123,7 @@ const styles = StyleSheet.create({
|
|
|
143
123
|
prefix:{
|
|
144
124
|
flexDirection: "row",
|
|
145
125
|
gap: 4,
|
|
146
|
-
alignItems:"center"
|
|
126
|
+
alignItems:"center",
|
|
127
|
+
paddingStart: 14,
|
|
147
128
|
}
|
|
148
129
|
});
|
|
@@ -2,30 +2,29 @@ import { registerValidator } from "../../utils/inputValidator/registerValidator"
|
|
|
2
2
|
|
|
3
3
|
registerValidator("text", (value, field) => {
|
|
4
4
|
if (field.required !== false && !value.trim())
|
|
5
|
-
return
|
|
5
|
+
return "errors.required";
|
|
6
6
|
return "";
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
registerValidator("email", (value) => {
|
|
10
|
-
if (!value.trim()) return "
|
|
10
|
+
if (!value.trim()) return "errors.required";
|
|
11
11
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
12
|
-
if (!emailRegex.test(value.trim())) return "
|
|
12
|
+
if (!emailRegex.test(value.trim())) return "errors.email";
|
|
13
13
|
return "";
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
registerValidator("password", (value, field, formState) => {
|
|
17
|
-
if (!value) return "
|
|
18
|
-
if (value.length < 8) return "
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return "Passwords do not match";
|
|
17
|
+
if (!value) return "errors.required";
|
|
18
|
+
if (value.length < 8) return "errors.passwordShort";
|
|
19
|
+
if (field.name === "confirmPassword" && value !== formState["password"]) {
|
|
20
|
+
return "errors.passwordMismatch";
|
|
22
21
|
}
|
|
23
22
|
return "";
|
|
24
23
|
});
|
|
25
24
|
|
|
26
25
|
registerValidator("phone", (value, field) => {
|
|
27
|
-
if (!value.trim()) return
|
|
26
|
+
if (!value.trim()) return "errors.required";
|
|
28
27
|
const phoneRegex = /^0[567]\d{8}$/;
|
|
29
|
-
if (!phoneRegex.test(value.trim())) return "
|
|
28
|
+
if (!phoneRegex.test(value.trim())) return "errors.phoneInvalid";
|
|
30
29
|
return "";
|
|
31
30
|
});
|