This PR addresses Issue #30 which requests that data validation be added using a package called joi to ensure a config is valid before importing or exporting.
Changes
Created a configSchema in Validation/config. Joi allows for building up complex schemas so I separately defined dialSchema, groupSchema, and settingsSchema which were combined to create the configSchema. This will make it easier to modify specific sections of the config without trying to break down one huge Joi schema definition.
Updated getData to allow it to throw an Error that can be caught by the function calling it. Since error-handling will likely be different depending on who/where data is being fetched, it makes more sense for the function to allow the error to bubble up and be handled by the parent function which has more context.
Added validation check to Welcome when supplying the initial configUrl.
Added validation to Settings when syncing the configUrl.
Added validation to Settings when exporting the current config to file.
Errors are all displayed in PopUpModal instances to ensure the user sees the error message and knows the operation was not successful.
Summary
This PR addresses Issue #30 which requests that data validation be added using a package called
joi
to ensure a config is valid before importing or exporting.Changes
configSchema
inValidation/config
. Joi allows for building up complex schemas so I separately defineddialSchema
,groupSchema
, andsettingsSchema
which were combined to create theconfigSchema
. This will make it easier to modify specific sections of the config without trying to break down one huge Joi schema definition.getData
to allow it to throw anError
that can be caught by the function calling it. Since error-handling will likely be different depending on who/where data is being fetched, it makes more sense for the function to allow the error to bubble up and be handled by the parent function which has more context.Welcome
when supplying the initialconfigUrl
.Settings
when syncing theconfigUrl
.Settings
when exporting the current config to file.PopUpModal
instances to ensure the user sees the error message and knows the operation was not successful.