- Event-Medien tragen Typ (image/video/audio), Dauer und Notiz; Videos bekommen ein Poster, Audio wird per ffmpeg nach AAC (audio/mp4) gewandelt, Originale werden mit Range-Unterstützung gestreamt. - Upload nimmt eine Notiz (caption) direkt mit, PATCH ändert sie später. - Neue Event-Felder: Zeitraum (end_date), Kategorie, Personen, Meilenstein. Regeln zentral in EventFields, damit CRUD und Sync gleich prüfen. - Titel darf leer sein: ein Event entsteht mit dem ersten Eintrag. - Artisan-Befehl media:transcode-voice-notes wandelt alte WebM/Ogg-Notizen, die Safari nicht abspielen kann. - Login-Throttling, Settings-Validierung, Sync-Fehlercodes ohne Rohtext. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
33 lines
908 B
PHP
33 lines
908 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
/**
|
|
* Allows only bounded scalar values inside the settings document, so a
|
|
* client cannot nest arrays or objects where a shader uniform or a colour
|
|
* string is expected.
|
|
*/
|
|
class ScalarSetting implements ValidationRule
|
|
{
|
|
public function __construct(private readonly int $maxLength = 4096) {}
|
|
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
if ($value === null || is_bool($value) || is_int($value) || is_float($value)) {
|
|
return;
|
|
}
|
|
|
|
if (! is_string($value)) {
|
|
$fail('The :attribute must be a string, number or boolean.');
|
|
|
|
return;
|
|
}
|
|
|
|
if (mb_strlen($value) > $this->maxLength) {
|
|
$fail("The :attribute may not be greater than {$this->maxLength} characters.");
|
|
}
|
|
}
|
|
}
|