Push empty object {} and recurrence doesn't change. #2483

This commit is contained in:
James Cole
2019-08-26 19:09:55 +02:00
parent f9dc58c3a8
commit 2b40b60d01
7 changed files with 346 additions and 227 deletions

View File

@@ -52,6 +52,24 @@ trait RecurrenceValidation
}
}
/**
* Adds an error to the validator when there are no repetitions in the array of data.
*
* @param Validator $validator
*/
public function validateOneRepetitionUpdate(Validator $validator): void
{
$data = $validator->getData();
$repetitions = $data['repetitions'] ?? null;
if (null === $repetitions) {
return;
}
// need at least one transaction
if (0 === count($repetitions)) {
$validator->errors()->add('repetitions', (string)trans('validation.at_least_one_repetition'));
}
}
/**
* Validates that the recurrence has valid repetition information. It either doesn't stop,
* or stops after X times or at X date. Not both of them.,