Update CBS Mobile App codebase
This commit is contained in:
+27
-1
@@ -2,7 +2,33 @@ export const isValidPhone = (value: string) => /^[0-9]{10}$/.test(value.replace(
|
||||
|
||||
export const isValidOtp = (value: string) => /^[0-9]{6}$/.test(value);
|
||||
|
||||
export const isValidMpin = (value: string) => /^[0-9]{4}$/.test(value);
|
||||
/**
|
||||
* Single source of truth for how many digits an MPIN has. The backend accepts
|
||||
* 4 or 6; this app standardises on 4, so the keypad, the validators and the
|
||||
* stored-profile handling all read from here rather than each hard-coding it.
|
||||
*/
|
||||
export const MPIN_LENGTH = 4;
|
||||
|
||||
/**
|
||||
* The backend refuses an all-same-digit MPIN. That rule is checked after
|
||||
* decryption server-side, so it comes back as a `VALIDATION_ERROR` with a
|
||||
* message rather than a field map — cheaper and clearer to catch it here
|
||||
* before spending a round trip.
|
||||
*/
|
||||
export const isValidMpin = (value: string) =>
|
||||
new RegExp(`^[0-9]{${MPIN_LENGTH}}$`).test(value) && !isRepeatedDigits(value);
|
||||
|
||||
export const isRepeatedDigits = (value: string) =>
|
||||
value.length > 0 && /^(\d)\1*$/.test(value);
|
||||
|
||||
/** Constraints as the API documents them, not as any one bank formats them. */
|
||||
export const isValidAccountNumber = (value: string) => /^[0-9]{5,20}$/.test(value);
|
||||
|
||||
export const isValidIfsc = (value: string) => /^[A-Za-z0-9]{6,15}$/.test(value);
|
||||
|
||||
export const isValidMmid = (value: string) => /^[0-9]{7}$/.test(value);
|
||||
|
||||
export const isValidNickname = (value: string) => value.length <= 60;
|
||||
|
||||
export const isValidAmount = (value: string) => {
|
||||
const amount = Number(value);
|
||||
|
||||
Reference in New Issue
Block a user