| 49 | }; |
| 50 | |
| 51 | export const getObjectDiff = ( |
| 52 | obj1: Record<string, unknown>, |
| 53 | obj2: Record<string, unknown>, |
| 54 | ): string[] => { |
| 55 | const diff = Object.keys(obj1).reduce((result, key) => { |
| 56 | if (!Object.prototype.hasOwnProperty.call(obj2, key)) { |
| 57 | result.push(key); |
| 58 | } else if ( |
| 59 | _.isEqual(obj1[key], obj2[key]) || |
| 60 | (obj1[key] === null && obj2[key] === '') || |
| 61 | (obj1[key] && |
| 62 | Array.isArray(obj1[key]) && |
| 63 | (obj1[key] as unknown[]).length === 0 && |
| 64 | obj2[key] === null) |
| 65 | ) { |
| 66 | const resultKeyIndex = result.indexOf(key); |
| 67 | if (resultKeyIndex >= 0) { |
| 68 | result.splice(resultKeyIndex, 1); |
| 69 | } |
| 70 | } |
| 71 | return result; |
| 72 | }, Object.keys(obj2)); |
| 73 | |
| 74 | return diff; |
| 75 | }; |
| 76 | |
| 77 | export const validateEmail = (email: string) => { |
| 78 | if (!email || email === '') return true; |