Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function extractValues(input) {
- // Extract object name
- let start = input.indexOf("object '") + 8;
- let end = input.indexOf("'", start);
- const objectName = input.substring(start, end);
- // Extract field name
- start = input.indexOf("$.") + 2;
- end = input.indexOf("':", start);
- const fieldName = input.substring(start, end);
- // Extract rejected value
- start = input.indexOf("rejected value [") + 16;
- end = input.indexOf("]", start);
- const rejectedValue = input.substring(start, end);
- return { objectName, fieldName, rejectedValue };
- }
- // Extract values from the string
- const { objectName, fieldName, rejectedValue } = extractValues(str);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement