Advertisement
SimpleCookie

Untitled

May 17th, 2024
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function extractValues(input) {
  2.   // Extract object name
  3.   let start = input.indexOf("object '") + 8;
  4.   let end = input.indexOf("'", start);
  5.   const objectName = input.substring(start, end);
  6.  
  7.   // Extract field name
  8.   start = input.indexOf("$.") + 2;
  9.   end = input.indexOf("':", start);
  10.   const fieldName = input.substring(start, end);
  11.  
  12.   // Extract rejected value
  13.   start = input.indexOf("rejected value [") + 16;
  14.   end = input.indexOf("]", start);
  15.   const rejectedValue = input.substring(start, end);
  16.  
  17.   return { objectName, fieldName, rejectedValue };
  18. }
  19.  
  20. // Extract values from the string
  21. const { objectName, fieldName, rejectedValue } = extractValues(str);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement