Compare commits

..

No commits in common. "08e954bba0710ea813a673bb6bd807484f53abaf" and "03f1f2bcf617f7e15f8407cb6940c46b0220f0d6" have entirely different histories.

2 changed files with 8 additions and 25 deletions

View File

@ -216,7 +216,6 @@ export const isValidPhoneNumber = (
return validatePhoneNumber(val, dialCode, country) === null; return validatePhoneNumber(val, dialCode, country) === null;
}; };
/** /**
* Updates the dial code prefix of an existing phone number when country changes. * Updates the dial code prefix of an existing phone number when country changes.
* Automatically clamps remaining digits to the new country's maxLength. * Automatically clamps remaining digits to the new country's maxLength.

View File

@ -65,7 +65,7 @@ export default function SignUpForm() {
const handlePhoneChange = (text: string) => { const handlePhoneChange = (text: string) => {
const digits = text.replace(/\D/g, ""); const digits = text.replace(/\D/g, "");
setPhone(digits.slice(0, selectedCountry.maxLength)); setPhone(digits.slice(0, 15));
if (phoneError) setPhoneError(""); if (phoneError) setPhoneError("");
}; };
@ -73,8 +73,8 @@ export default function SignUpForm() {
setSelectedCountry(c); setSelectedCountry(c);
setShowCountryModal(false); setShowCountryModal(false);
setCountrySearch(""); setCountrySearch("");
if (phone.length > c.maxLength) { if (phone.length > 15) {
setPhone(phone.slice(0, c.maxLength)); setPhone(phone.slice(0, 15));
} }
if (phoneError) setPhoneError(""); if (phoneError) setPhoneError("");
}; };
@ -101,13 +101,9 @@ export default function SignUpForm() {
} }
if (phone.trim()) { if (phone.trim()) {
const err = validatePhoneNumber( const digits = phone.trim().replace(/\D/g, "");
phone.trim(), if (digits.length < 7 || digits.length > 15) {
selectedCountry.code, setPhoneError("Phone number must be between 7 and 15 digits");
selectedCountry.country
);
if (err) {
setPhoneError(err);
hasError = true; hasError = true;
} }
} }
@ -235,19 +231,13 @@ export default function SignUpForm() {
autoCapitalize="none" autoCapitalize="none"
autoCorrect={false} autoCorrect={false}
textContentType="telephoneNumber" textContentType="telephoneNumber"
maxLength={selectedCountry.maxLength} maxLength={15}
style={styles.phoneInput} style={styles.phoneInput}
/> />
</View> </View>
{phoneError ? ( {phoneError ? (
<Text style={styles.errorText}>{phoneError}</Text> <Text style={styles.errorText}>{phoneError}</Text>
) : ( ) : null}
<Text style={styles.phoneHelperText}>
{selectedCountry.minLength === selectedCountry.maxLength
? `${selectedCountry.country}: Requires exactly ${selectedCountry.maxLength} digits`
: `${selectedCountry.country}: ${selectedCountry.minLength} to ${selectedCountry.maxLength} digits`}
</Text>
)}
</View> </View>
<PasswordInput <PasswordInput
@ -447,12 +437,6 @@ const styles = StyleSheet.create({
marginTop: verticalScale(6), marginTop: verticalScale(6),
marginLeft: scale(6), marginLeft: scale(6),
}, },
phoneHelperText: {
color: AuthColors.textSecondary,
fontSize: moderateScale(11),
marginTop: verticalScale(4),
marginLeft: scale(6),
},
modalOverlay: { modalOverlay: {
flex: 1, flex: 1,