Skip to content

Conversation

elpete
Copy link
Contributor

@elpete elpete commented Oct 8, 2025

Description

When using validateOrFail, the top level keys of the struct are filtered to only return the keys matching a constraint. This has not applied to nested structs and arrays. This PR fixes that behavior.

Issues

https://ortussolutions.atlassian.net/browse/BOX-161

Type of change

Please delete options that are not relevant.

  • Bug Fix
  • Improvement
  • New Feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project cfformat
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@elpete elpete requested a review from Copilot October 8, 2025 20:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the validateOrFail method to properly filter nested structs and arrays, ensuring that only keys matching validation constraints are returned at all levels of the data structure. Previously, filtering only applied to top-level keys.

Key changes:

  • Refactored the filtering logic in ValidationManager.cfc to handle nested structures recursively
  • Added comprehensive tests for nested struct and array filtering scenarios
  • Updated test handler with a new endpoint to test nested validation filtering

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
models/ValidationManager.cfc Extracted filtering logic into a recursive private method that handles nested structs and arrays
test-harness/handlers/Main.cfc Added new test endpoint with nested constraints and code formatting improvements
test-harness/tests/specs/ValidationIntegrations.cfc Added comprehensive test case for nested struct and array filtering validation

@elpete
Copy link
Contributor Author

elpete commented Oct 8, 2025

The failing test seems due to testing using ColdBox which is not yet BoxLang Prime certified.

@elpete elpete self-assigned this Oct 8, 2025
@elpete elpete requested a review from lmajano October 8, 2025 20:02
@elpete elpete requested a review from Copilot October 8, 2025 20:04
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

@jclausen jclausen merged commit a4e5f76 into development Oct 9, 2025
33 checks passed
@jclausen jclausen deleted the filtering_nested_constraints branch October 9, 2025 18:49
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.

2 participants