Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/validation.js
Show First 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | try { | ||||
const isValid = typeof settings === 'object' && isValidSettingParams; | const isValid = typeof settings === 'object' && isValidSettingParams; | ||||
return isValid; | return isValid; | ||||
} catch (err) { | } catch (err) { | ||||
return false; | return false; | ||||
} | } | ||||
}; | }; | ||||
export const parseInvalidSettingsForMigration = invalidCashtabSettings => { | |||||
// create a copy of the invalidCashtabSettings | |||||
let migratedCashtabSettings = invalidCashtabSettings; | |||||
// determine if settings are invalid because it is missing a parameter | |||||
for (let param in currency.defaultSettings) { | |||||
if ( | |||||
!Object.prototype.hasOwnProperty.call(invalidCashtabSettings, param) | |||||
) { | |||||
// adds the default setting for only that parameter | |||||
migratedCashtabSettings[param] = currency.defaultSettings[param]; | |||||
} | |||||
} | |||||
return migratedCashtabSettings; | |||||
}; | |||||
export const isValidContactList = contactList => { | export const isValidContactList = contactList => { | ||||
/* | /* | ||||
A valid contact list is an array of objects | A valid contact list is an array of objects | ||||
An empty contact list looks like [{}] | An empty contact list looks like [{}] | ||||
Although a valid contact list does not contain duplicated addresses, this is not checked here. | Although a valid contact list does not contain duplicated addresses, this is not checked here. | ||||
This is checked for when contacts are added. Duplicate addresses will not break the app if a user | This is checked for when contacts are added. Duplicate addresses will not break the app if a user | ||||
somehow sideloads a contact list with everything valid except some addresses are duplicated. | somehow sideloads a contact list with everything valid except some addresses are duplicated. | ||||
▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines |