Skip to content

[codex] Support error path mapping#178

Merged
66Ton99 merged 1 commit into
formapro:masterfrom
66Ton99:codex/pr113-error-path-mapping
Jun 4, 2026
Merged

[codex] Support error path mapping#178
66Ton99 merged 1 commit into
formapro:masterfrom
66Ton99:codex/pr113-error-path-mapping

Conversation

@66Ton99
Copy link
Copy Markdown
Collaborator

@66Ton99 66Ton99 commented Jun 4, 2026

Supersedes the useful behavior from #113 with a small modern patch against the current codebase.

Plan

  • Add a structured JavaScript error object for custom constraints that need Symfony-like atPath() behavior.
  • Keep existing constraints that return plain strings backward-compatible.
  • Route mapped errors to child form elements and clear routed errors on revalidation.
  • Document the API and add focused Jest coverage.

Changes

  • Introduces FpJsFormError(message) with optional atPath.
  • Converts string validation errors into FpJsFormError during validation.
  • Resolves direct and nested child paths from the validated element, falling back to the validated element when the path is unknown.
  • Clears the current validation source recursively before each validation pass so routed child errors do not remain after the owner constraint becomes valid.
  • Documents error path mapping in src/Resources/doc/3_2.md.

Tests

  • npm run test:unit -- FpJsFormValidator.test.js --runInBand
  • php /tmp/jsfv-composer.phar validate --strict
  • php /tmp/jsfv-composer.phar test
  • npm test
  • git diff --check

Introduce FpJsFormError so custom constraints can return structured errors with an atPath value. Resolve the path from the validated element and route the error message to the matching child element, with fallback to the validated element when the path is unknown.

Keep existing string-returning constraints backward-compatible by converting strings to FpJsFormError during validation. Clear the current validation source recursively before each validation pass so routed errors disappear after the constraint becomes valid.

Document the custom constraint API and cover direct, nested, fallback, string-error, revalidation, and model-only DOM cases in Jest.

Co-authored-by: Codex <codex@openai.com>
@66Ton99 66Ton99 marked this pull request as ready for review June 4, 2026 17:05
@66Ton99 66Ton99 merged commit e749cb3 into formapro:master Jun 4, 2026
4 checks passed
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.

1 participant