*/ public static function lines(string $value): array { return array_values(array_filter(array_map(trim(...), explode("\n", $value)), fn (string $line): bool => $line !== '')); } /** * Describes the rule in the generated API documentation. * * @return array{description: string} */ public function docs(): array { return ['description' => 'One image per line, optionally prefixed with a display name and a pipe (Java 21|ghcr.io/pterodactyl/yolks:java_21). Each must be at most 191 characters and match the regex /^[\w#\.\/\- ]*\|?~?[\w\.\/\-:@ ]*$/.']; } public function validate(string $attribute, mixed $value, Closure $fail): void { if (! is_string($value)) { return; } $images = self::lines($value); if ($images === []) { $fail('The :attribute field must list at least one image.'); return; } foreach ($images as $image) { if (Validator::make(['image' => $image], ['image' => CreateEgg::DOCKER_IMAGE])->fails()) { $fail(sprintf('The :attribute entry "%s" is not a valid Docker image.', Str::limit($image, 64))); return; } } } }