From 9f5010aca2a9b5861219c2addf09a23a1fda6806 Mon Sep 17 00:00:00 2001
From: Yash Mittal <mittal.yash12@hotmail.com>
Date: Thu, 13 Jun 2024 17:50:19 +0530
Subject: [PATCH] fix: guards on decryption

---
 src/xstate/prompt/prompt.gaurds.ts | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

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!",