Skip to content

Commit

Permalink
[FIX] regex check only base58 substring without altering the original…
Browse files Browse the repository at this point in the history
… string
  • Loading branch information
gabrielbazan7 committed Jan 15, 2025
1 parent eff68f7 commit 0bf1d2d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/navigation/wallet/screens/JoinMultisig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,17 @@ const JoinMultisig = ({navigation, route}: JoinScreenProps) => {
invitationCode: yup
.string()
.required()
.matches(/^[0-9A-HJ-NP-Za-km-z]{70,80}$/, t('InvalidInvitationCode')),
.trim()
.test(
'valid-invitation-code',
t('InvalidInvitationCode'),
(value) => {
if (!value) return false;
const partToValidate = value.slice(0, -4); // assuming network + chain is always 4 characters eg Lbtc
const regex = /^[0-9A-HJ-NP-Za-km-z]{70,80}$/;
return regex.test(partToValidate);
}
),
});
const {
control,
Expand Down Expand Up @@ -269,7 +279,7 @@ const JoinMultisig = ({navigation, route}: JoinScreenProps) => {
control={control}
render={({field: {onChange, onBlur, value}}) => (
<BoxInput
onChangeText={(text: string) => onChange(text)}
onChangeText={(text: string) => onChange(text.trim())}
onBlur={onBlur}
value={value}
error={errors.invitationCode?.message}
Expand Down

0 comments on commit 0bf1d2d

Please sign in to comment.