chg: [settingTable] Added value validation before saving the setting
parent
e13b4e7bc5
commit
ad3e89199b
|
@ -74,10 +74,18 @@ class SettingsTable extends AppTable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$setting['value'] = $value ?? '';
|
$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'])) {
|
if (empty($errors) && !empty($setting['beforeSave'])) {
|
||||||
$beforeSaveResult = $this->SettingsProvider->evaluateFunctionForSetting($setting['beforeSave'], $setting);
|
$beforeSaveResult = $this->SettingsProvider->evaluateFunctionForSetting($setting['beforeSave'], $setting);
|
||||||
if ($beforeSaveResult !== true) {
|
if ($beforeSaveResult !== true) {
|
||||||
$errors[] = $beforeSaveResult;
|
$errors[] = $beforeSaveResult;
|
||||||
|
$setting['errorMessage'] = $validationResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($errors)) {
|
if (empty($errors)) {
|
||||||
|
|
Loading…
Reference in New Issue