Skip to content

Comments

New Feature: Report all validation errors instead of stopping at the first one#26

Merged
wadakatu merged 8 commits intomainfrom
feat/report-all-validation-errors
Feb 22, 2026
Merged

New Feature: Report all validation errors instead of stopping at the first one#26
wadakatu merged 8 commits intomainfrom
feat/report-all-validation-errors

Conversation

@wadakatu
Copy link
Collaborator

概要

OpenApiResponseValidator がデフォルトで最大20件のバリデーションエラーを一括報告するようになりました。これまではスキーマ違反が1件見つかった時点で停止していたため、開発者は fix → run → fix のサイクルを繰り返す必要がありました。

変更内容

  • OpenApiResponseValidatormaxErrors コンストラクタパラメータを追加(デフォルト: 20
    • 0 は無制限(PHP_INT_MAX)として扱う
    • maxErrors === 1 の場合のみ stopAtFirstError: true で動作(従来の挙動)
  • Laravel 設定ファイルに max_errors キーを追加(デフォルト: 20
  • ValidatesOpenApiSchema トレイトが max_errors 設定値を読み取り、バリデータに渡すよう更新
  • maxErrors の挙動を検証するユニットテストを3件追加
  • README に maxErrors パラメータのドキュメントを追加

関連情報

Add a `maxErrors` constructor parameter (default: 20, 0 = unlimited
via PHP_INT_MAX) and pass it to the opis/json-schema Validator.
`stopAtFirstError` is true only when maxErrors is 1.
Reject negative maxErrors values with InvalidArgumentException to
enforce the contract that maxErrors must be 0 (unlimited) or positive.
Change is_int() guard to is_numeric() + (int) cast so that string
values returned by env() (e.g. "10") are accepted instead of silently
falling back to the default.
- Use 50-item payloads to prove truncation works in maxErrors tests
- Add capped vs unlimited comparison, boundary, and negative input tests
- Add Laravel trait tests for max_errors config, string casting, and fallback
- Change "original behavior" to "pre-v0.x default" in the maxErrors: 1
  code comment to avoid misleading upgrading users
- Reword API Reference description from "controlling how many schema
  errors are collected before stopping" to "that limits how many
  validation errors the underlying JSON Schema validator collects"
@wadakatu wadakatu merged commit 9b36db5 into main Feb 22, 2026
8 checks passed
@wadakatu wadakatu deleted the feat/report-all-validation-errors branch February 22, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report all validation errors instead of stopping at the first one

1 participant