diff --git a/src/xstate/prompt/prompt.gaurds.ts b/src/xstate/prompt/prompt.gaurds.ts index ca11193..6d09e64 100644 --- a/src/xstate/prompt/prompt.gaurds.ts +++ b/src/xstate/prompt/prompt.gaurds.ts @@ -6,12 +6,20 @@ export const promptGuards = { ifMultipleAadhaar: (_, event) => event.data == "This mobile number taged with multiple records.", - ifInValidScheme: (_, event) => - !VALID_SCHEMES.includes(event.data.prompt.input.schemeName), - - ifNoRecordsFound: (context, event) => - event.data == - `No Record Found for this (${context.userAadhaarNumber}) Aadhar/Ben_id/Mobile.`, + // ifInValidScheme: (_, event) => + // !VALID_SCHEMES.includes(event.data.prompt.input.schemeName), + + ifNoRecordsFound: (context, event) => { + const pattern = + /No Record Found for this \((.*?)\) Aadhar\/Ben_id\/Mobile\./; + return ( + pattern.test(event.data) || + ((event.data as string).startsWith("No Record Found for this") && + (event.data as string).endsWith("Aadhar/Ben_id/Mobile.")) + ); + }, + // event.data == + // `No Record Found for this (${context.userAadhaarNumber}) Aadhar/Ben_id/Mobile.`, ifOTPSend: (_, event) => event.data == "OTP send successfully!",