Find crop codes under crop and document unreadable avatar files

This commit is contained in:
envoyr committed 2026-11-07 00:36:52 +00:00
1 parent 0ccf46d69a
commit 57efac2bf5
5 files changed
+52 -5

No files matched your search

@@ -19,9 +19,25 @@ class ValidationFailedException extends ApiException
return is_object($codes) || is_array($codes) ? array_map('strval', (array) $codes) : [];
}
/**
* The code of $field, or of its first failed sub-field when the codes are keyed by those
* (`crop` finds `crop.x`, `crop.y` or `crop.size`).
*/
public function errorCodeFor(string $field): ?string
{
return $this->errorCodes()[$field] ?? null;
$codes = $this->errorCodes();
if (isset($codes[$field])) {
return $codes[$field];
}
foreach ($codes as $key => $code) {
if (str_starts_with((string) $key, $field . '.')) {
return $code;
}
}
return null;
}
/**