Skip to content

Comments

REST API: Add Validation#1001

Merged
n7studios merged 2 commits intouse-rest-apifrom
use-rest-api-resources-validation
Feb 3, 2026
Merged

REST API: Add Validation#1001
n7studios merged 2 commits intouse-rest-apifrom
use-rest-api-resources-validation

Conversation

@n7studios
Copy link
Contributor

Summary

Adds validation and sanitization to the args section of register_rest_route, ensuring the WP REST API validates and sanitizes inputs before using the callback.

This ensures correct HTTP status codes are returned e.g. 400 for when an invalid request is made vs. the current 500 server error, which is inaccurate.

Testing

Existing tests pass.

Checklist

@n7studios n7studios self-assigned this Jan 26, 2026
@github-actions
Copy link

WordPress Playground

🚀 Your PR has been built and is ready for testing in WordPress Playground!

Click here to test your changes in WordPress Playground

@n7studios n7studios requested review from a team, ciccio-kit and noelherrick and removed request for a team January 26, 2026 12:06
@n7studios n7studios marked this pull request as ready for review January 26, 2026 12:06
Copy link

@ciccio-kit ciccio-kit left a comment

Choose a reason for hiding this comment

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

LGTM ✅

@n7studios n7studios merged commit 7295e04 into use-rest-api Feb 3, 2026
225 of 233 checks passed
@n7studios n7studios deleted the use-rest-api-resources-validation branch February 10, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants