Skip to content

updated type of the spatial validator#687

Closed
ArnabChatterjee20k wants to merge 7 commits into1.xfrom
spatial-validator-update
Closed

updated type of the spatial validator#687
ArnabChatterjee20k wants to merge 7 commits into1.xfrom
spatial-validator-update

Conversation

@ArnabChatterjee20k
Copy link
Contributor

@ArnabChatterjee20k ArnabChatterjee20k commented Sep 5, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Spatial field validation is now treated as an array type, ensuring consistent detection and processing across forms, API payloads, and error reporting.
    • Resolves prior misidentification of spatial data that could cause validation edge cases.
    • Improves compatibility with array-based rules, schema generation, and client-side validators.
    • No public API changes or breaking changes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 5, 2025

Walkthrough

The Spatial validator now reports it handles array data: isArray() returns true, and getType() returns TYPE_ARRAY. No other validation logic or public signatures were changed.

Changes

Cohort / File(s) Summary
Spatial validator type flags
src/Database/Validator/Spatial.php
isArray() return flipped to true; getType() now returns self::TYPE_ARRAY; validation logic unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • abnegate

Poem

I hop through fields of code so spry,
Spatial now says “arrays, aye!”
Types aligned, the flags obey,
No logic shifted on the way.
Thump-thump! My reviews are light—
Just two small flips, and all is right. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch spatial-validator-update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/Database/Validator/Spatial.php (1)

113-117: Polygon closure check is too strict for numeric strings vs numbers.

Using !== can fail when first/last points are numerically equal but differ by type (e.g., "1" vs 1). Consider numeric comparison with tolerance.

Apply:

-            // Check that the ring is closed (first point == last point)
-            if ($ring[0] !== $ring[count($ring) - 1]) {
+            // Check that the ring is closed (first point ~= last point)
+            $first = array_map('floatval', $ring[0]);
+            $last  = array_map('floatval', $ring[count($ring) - 1]);
+            $epsilon = 1e-9;
+            if (abs($first[0] - $last[0]) > $epsilon || abs($first[1] - $last[1]) > $epsilon) {
                 $this->message = "Ring #{$ringIndex} must be closed (first point must equal last point)";
                 return false;
             }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e4a03ba and 6d280f4.

📒 Files selected for processing (1)
  • src/Database/Validator/Spatial.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Database/Validator/Spatial.php (2)
src/Database/Validator/Queries.php (1)
  • getType (165-168)
src/Database/Validator/Structure.php (1)
  • getType (427-430)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Setup & Build Docker Image
🔇 Additional comments (2)
src/Database/Validator/Spatial.php (2)

142-145: Confirm no external dependencies on the ‘spatial’ type
Ripgrep found no getType() === 'spatial' checks or TYPE_SPATIAL usages in src/; since getType() now returns TYPE_ARRAY, manually audit any serializers, schema generators, SDKs, or client code that might expect a 'spatial' literal.


137-140: Spatial::isArray() now returns true – verify no upstream logic misinterprets arrays as element collections

Spatial::isArray() was flipped from false to true. Search for any code using isArray() (or alongside getType()) to gate or iterate inputs before validation—ensure WKT strings aren’t being rejected or their elements processed individually.

@abnegate abnegate changed the base branch from main to 1.x September 5, 2025 13:20
@ArnabChatterjee20k
Copy link
Contributor Author

wrong branch so closing as it would lead to breaking change

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