chore: checkpoint before block builder refactor

This commit is contained in:
2026-04-03 23:03:09 +02:00
parent 330950cc6e
commit 4f3fefca5c
14 changed files with 315 additions and 99 deletions

View File

@@ -6,6 +6,7 @@ namespace App\Http\Requests;
use App\Models\PreregistrationPage;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Email;
class SubscribePublicPageRequest extends FormRequest
{
@@ -22,13 +23,28 @@ class SubscribePublicPageRequest extends FormRequest
/** @var PreregistrationPage $page */
$page = $this->route('publicPage');
$emailRule = (new Email)
->rfcCompliant()
->preventSpoofing();
return [
'first_name' => ['required', 'string', 'max:255'],
'last_name' => ['required', 'string', 'max:255'],
'email' => ['required', 'email', 'max:255'],
'email' => ['required', 'string', 'max:255', $emailRule],
'phone' => $page->phone_enabled
? ['required', 'string', 'max:20']
: ['nullable', 'string', 'max:20'],
? ['nullable', 'string', 'regex:/^[0-9]{8,15}$/']
: ['nullable', 'string', 'max:255'],
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return [
'email' => __('Please enter a valid email address.'),
'phone.regex' => __('Please enter a valid phone number (815 digits).'),
];
}
@@ -53,5 +69,18 @@ class SubscribePublicPageRequest extends FormRequest
'email' => strtolower(trim($email)),
]);
}
/** @var PreregistrationPage $page */
$page = $this->route('publicPage');
$phone = $this->input('phone');
if (! $page->phone_enabled) {
$this->merge(['phone' => null]);
return;
}
if (is_string($phone)) {
$digits = preg_replace('/\D+/', '', $phone);
$this->merge(['phone' => $digits === '' ? null : $digits]);
}
}
}