chg: [settingTable] Added value validation before saving the setting

cli-modification-summary
Sami Mokaddem 2022-02-07 12:01:07 +01:00
parent e13b4e7bc5
commit ad3e89199b
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 8 additions and 0 deletions

View File

@ -74,10 +74,18 @@ class SettingsTable extends AppTable
}
}
$setting['value'] = $value ?? '';
if (isset($setting['test'])) {
$validationResult = $this->SettingsProvider->evaluateFunctionForSetting($setting['test'], $setting);
if ($validationResult !== true) {
$errors[] = $validationResult;
$setting['errorMessage'] = $validationResult;
}
}
if (empty($errors) && !empty($setting['beforeSave'])) {
$beforeSaveResult = $this->SettingsProvider->evaluateFunctionForSetting($setting['beforeSave'], $setting);
if ($beforeSaveResult !== true) {
$errors[] = $beforeSaveResult;
$setting['errorMessage'] = $validationResult;
}
}
if (empty($errors)) {