br-write-schema

Validate WordPress Resource payloads with per-field writeSchema constraints.

21|1|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill br-write-schema
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: br-write-schema
Source: https://github.com/Lonsdale201/wp-agent-skills/tree/main/better-route/br-write-schema
Command: npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill br-write-schema

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables developers to enforce consistent payload validation for WordPress Resource endpoints by applying a per-field schema via writeSchema and payloadSchema, ensuring data is coerced, sanitized, and validated before handlers run.

Core Features & Use Cases

  • Per-field rule shapes that drive type coercion, sanitization, and constraint checks.
  • Flat enum shape support with explicit 'values' list.
  • Aliases for common types to keep code consistent (int ↔ integer, float ↔ number, bool ↔ boolean).
  • Error reporting via validation_failed with details.fieldErrors.
  • Usage across create (POST) and update (PUT/PATCH) workflows; reuse across resources via writeSchema / payloadSchema.

Quick Start

Define a writeSchema on your Resource to validate incoming payloads and ensure errors surface as fieldErrors on failure.

Frequently Asked Questions about br-write-schema

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate API payloads for WordPress Resource endpoints?

You can validate API payloads by defining a writeSchema on your WordPress Resource to apply per-field constraints, type coercion, and sanitization before handlers run. This ensures incoming data is checked and errors are reported as fieldErrors in a 400 response.

What is the best way to enforce per-field constraints on POST and PUT requests in PHP?

The best way to enforce per-field constraints on POST and PUT requests is to use a schema definition that checks required fields, nullable handling, and min/max length constraints. This approach validates and coerces payload data before it reaches your handlers.

How does schema validation handle API errors and failed payload checks?

When payload validation fails, the schema throws an ApiException with the code validation_failed. The system then returns a 400 HTTP response that includes details in the fieldErrors object, identifying the specific fields that did not meet the constraints.

Can I reuse validation schemas across multiple WordPress Resource endpoints?

Yes, you can reuse validation schemas across multiple WordPress Resource endpoints by defining them via writeSchema or payloadSchema. This allows consistent payload validation and sanitization across different resources without duplicating rule definitions.

Does payload schema validation support enum values and type aliases?

Yes, payload schema validation supports a flat enum shape with an explicit values list and provides aliases for common types like int for integer and bool for boolean. This simplifies schema definitions while maintaining strict constraint checks.