mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup
This commit is contained in:
@@ -42,38 +42,38 @@ trait ValidatesAutoBudgetRequest
|
||||
/** @var null|float|int|string $amount */
|
||||
$amount = array_key_exists('auto_budget_amount', $data) ? $data['auto_budget_amount'] : null;
|
||||
$period = array_key_exists('auto_budget_period', $data) ? $data['auto_budget_period'] : null;
|
||||
$currencyId = array_key_exists('auto_budget_currency_id', $data) ? (int)$data['auto_budget_currency_id'] : null;
|
||||
$currencyId = array_key_exists('auto_budget_currency_id', $data) ? (int) $data['auto_budget_currency_id'] : null;
|
||||
$currencyCode = array_key_exists('auto_budget_currency_code', $data) ? $data['auto_budget_currency_code'] : null;
|
||||
if (is_numeric($type)) {
|
||||
$type = (int)$type;
|
||||
$type = (int) $type;
|
||||
}
|
||||
if ('' === $type || 0 === $type) {
|
||||
return;
|
||||
}
|
||||
// TODO lots of duplicates with number validator.
|
||||
// TODO should be present at more places, stop scientific notification
|
||||
if (str_contains(strtoupper((string)$amount), 'E')) {
|
||||
if (str_contains(strtoupper((string) $amount), 'E')) {
|
||||
$amount = '';
|
||||
}
|
||||
// basic float check:
|
||||
if (!is_numeric($amount)) {
|
||||
$validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));
|
||||
$validator->errors()->add('auto_budget_amount', (string) trans('validation.amount_required_for_auto_budget'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (1 !== bccomp((string)$amount, '0')) {
|
||||
$validator->errors()->add('auto_budget_amount', (string)trans('validation.auto_budget_amount_positive'));
|
||||
if (1 !== bccomp((string) $amount, '0')) {
|
||||
$validator->errors()->add('auto_budget_amount', (string) trans('validation.auto_budget_amount_positive'));
|
||||
}
|
||||
if ('' === $period) {
|
||||
$validator->errors()->add('auto_budget_period', (string)trans('validation.auto_budget_period_mandatory'));
|
||||
$validator->errors()->add('auto_budget_period', (string) trans('validation.auto_budget_period_mandatory'));
|
||||
}
|
||||
if (null !== $currencyId && null !== $currencyCode && '' === $currencyCode && 0 === $currencyId) {
|
||||
$validator->errors()->add('auto_budget_amount', (string)trans('validation.require_currency_info'));
|
||||
$validator->errors()->add('auto_budget_amount', (string) trans('validation.require_currency_info'));
|
||||
}
|
||||
// too big amount
|
||||
if ((int)$amount > 268435456) {
|
||||
$validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));
|
||||
if ((int) $amount > 268435456) {
|
||||
$validator->errors()->add('auto_budget_amount', (string) trans('validation.amount_required_for_auto_budget'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user