Rule controller can handle empty submission. #2477

The rule repository can't handle this (yet).
This commit is contained in:
James Cole
2019-08-25 07:48:46 +02:00
parent e16adca336
commit c0909aebba
4 changed files with 238 additions and 61 deletions

View File

@@ -186,6 +186,10 @@ class Request extends FormRequest
*/
public function nullableInteger(string $field): ?int
{
if (!$this->has($field)) {
return null;
}
$value = (string)$this->get($field);
if ('' === $value) {
return null;
@@ -203,9 +207,10 @@ class Request extends FormRequest
*/
public function nullableString(string $field): ?string
{
$string = app('steam')->cleanString((string)($this->get($field) ?? ''));
return '' === $string ? null : $string;
if (!$this->has($field)) {
return null;
}
return app('steam')->cleanString((string)($this->get($field) ?? ''));
}
/**