How to Create a Validation Rule Schema for WordPress Content Checks

Person filling out a form on a clipboard

Last updated: November 27, 2026

Quick Answer: a solid validation rule schema for WordPress content checks usually needs 6 fields: id, name, field, condition, severity, and remediation. In practical terms, How to create a validation rule schema for WordPress content checks means defining a structured rule object that says what to inspect, which field to inspect, what condition to apply, how severe a failure is, and what message should guide the editor. If the schema is clear, one rule can be read by a human, stored in JSON, and run by code without guesswork.

Key Takeaways

  • A schema can store the rule name, field scope, condition, severity, and remediation in one object.
  • Stable keys help the same rule pattern scale from 5 rules to 50 rules.
  • One condition should describe one test that code can evaluate without guessing.
  • Field and scope should show where the validator looks and how far the check reaches.

What should the schema record?

A validation rule schema should record the rule name, field scope, condition, severity, and remediation message in one predictable object. That is the minimum that turns a loose checklist into something a WordPress plugin, theme, or custom publish flow can evaluate at run time.

A good schema usually holds one rule object per check. That keeps each rule small enough to review and change without touching the others. It also makes it easier to sort rules by stage, such as draft review, pre-publish, or post-save checks, instead of stuffing 20 checks into one giant blob. See also the validation rules by publishing stage hub for stage-level organization.

A simple rule record can look like this:

json
{
"id": "title-length",
"name": "Title length",
"field": "post_title",
"condition": {
"operator": "between",
"min": 40,
"max": 65
},
"severity": "warning",
"remediation": "Shorten the title so it stays readable in search results."
}

That structure is useful because it tells the system exactly what to test and what to say back to the editor. It is also narrow enough to compare across rules in a single 1-page view or a JSON file, which matters when a site has 10, 30, or more checks.

The biggest mistake is to mix rule data with workflow logic. A schema should describe the rule, not decide who approves the post, how many people must sign off, or whether a draft can publish. Those are different problems.

How do you define the rule object?

A rule object should use stable keys so the same pattern works for 5 rules or 50 rules. That means the object needs a unique id, a human-readable name, one field, one condition, one severity, and one remediation message.

Hand writing on a clipboard form
Photo: rdne via Pexels

A useful set of fields looks like this:

  • id: a machine key like excerpt-required
  • name: a label an editor can read
  • field: the WordPress field or content path being checked
  • condition: the test logic
  • severity: how serious the failure is
  • remediation: the message shown when the rule fails

That list is small on purpose. If the object tries to hold every possible setting, it becomes hard to scan and harder to reuse. A schema that fits on one screen is easier to maintain than one that takes 4 screens and 12 nested objects.

A reusable example:

json
{
"id": "excerpt-word-count",
"name": "Excerpt length",
"field": "excerpt",
"condition": {
"operator": "maxWords",
"value": 30
},
"severity": "warning",
"remediation": "Trim the excerpt to 30 words or fewer."
}

Notice that field points at one content area and condition describes one test. That split matters because it keeps the target separate from the logic. If you later need the same rule for post_content, you only change the field scope, not the logic itself.

The rule object is wrong for sites that want full workflow automation inside the same record. If the goal is approval routing, editorial assignment, or status changes, that belongs in another layer. A validation schema should stay focused on checks. For WordPress content models, the WordPress REST API handbook is a useful reference for field shapes and endpoints, while JSON Schema is a useful reference for object structure.

What should the condition describe?

A condition should describe one test in a form code can evaluate without guessing. In practice, that means the condition names the operator and supplies the values it needs, such as a minimum, maximum, list, pattern, or expected state.

For WordPress content checks, common condition shapes include:

  • equals
  • notEquals
  • contains
  • matches
  • greaterThan
  • lessThan
  • between
  • minWords
  • maxWords

That set is enough for most publishing rules without making the schema cluttered. If you need 14 custom operators on day one, the schema is probably carrying too much logic.

Here is a title rule and a content rule side by side:

json
{
"id": "title-pattern",
"name": "Title uses a clear format",
"field": "post_title",
"condition": {
"operator": "matches",
"pattern": "^[A-Z].{9,}$"
},
"severity": "warning",
"remediation": "Start with a capital letter and avoid very short titles."
}

json
{
"id": "content-min-length",
"name": "Body text length",
"field": "post_content",
"condition": {
"operator": "minWords",
"value": 300
},
"severity": "error",
"remediation": "Add enough body text to meet the minimum."
}

A condition should not try to judge everything at once. A single rule should check one thing: length, pattern, presence, or range. That keeps failures easy to explain. It also keeps the remediation message honest, because the message can point to one fix instead of a vague rewrite.

For a formal reference model, JSON Schema is a useful source of shape and naming ideas, especially for how objects, required keys, and value constraints are expressed. See the JSON Schema project’s documentation at https://json-schema.org/understanding-json-schema/ for the core pattern.

How do you choose fields and scope?

A field and its scope should tell the validator where to look and how wide the check should reach. In WordPress, that can mean a core field like post_title, a block attribute, a custom field, or a nested path inside structured content.

This is where many schemas go wrong. They name the field too loosely, such as “title” or “meta,” and then the validator has to guess whether it means the post title, a custom field, or a block label. That guesswork breaks the rule the moment the content model changes.

A clear schema should use field paths that are stable and specific. Examples:

  • post_title
  • post_excerpt
  • post_content
  • meta.seo_description
  • blocks[0].attrs.heading

Those examples show why scope matters. A rule for post_title checks the whole title field. A rule for blocks[0].attrs.heading checks one block attribute in one block position. The second is narrower and more fragile, but it may be the right fit for a single template.

A schema should also state whether the rule applies to all posts, only posts with a certain template, or only one content type. That scope can be stored as a separate property, such as:

json
{
"id": "hero-heading-case",
"name": "Hero heading format",
"field": "blocks.hero.attrs.heading",
"scope": {
"postType": "page",
"template": "landing-page"
},
"condition": {
"operator": "matches",
"pattern": "^[A-Z]"
},
"severity": "warning",
"remediation": "Rewrite the hero heading to start with a capital letter."
}

Without scope, one rule may fire on content where it does not belong. That creates false alarms and trains editors to ignore warnings. A schema that is tight at the field level is easier to trust.

The WordPress REST API handbook is a useful reference for how WordPress exposes content fields and structured data through endpoints. See https://developer.wordpress.org/rest-api/ for the shape of WordPress content data and the fields available to code.

How do severity and remediation work together?

Severity and remediation should tell the editor how serious the failure is and what to do next in one pass. Severity gives the system a priority level; remediation gives the person reading the result the fix.

A common three-level model is enough for many WordPress publishing setups:

Severity Meaning Typical use
info No block, just guidance Style or preference checks
warning Needs attention Readability, consistency, or formatting issues
error Should block publish Missing or invalid content that must be fixed
Comparison table of How do severity and remediation work together?
Comparison table: How do severity and remediation work together?

That table works better than a long list of custom levels because it keeps editorial behavior predictable. If every rule has a unique severity, the team has to relearn the system for each check.

The remediation message should be specific, short, and tied to the failing field. “Fix this field” is weak. “Add 2 sentences to post_excerpt” is stronger because it names the target and the action. The message should also avoid overpromising; if the rule only checks word count, it should not claim the content is ready to publish in every other respect.

Example:

json
{
"id": "excerpt-present",
"name": "Excerpt exists",
"field": "post_excerpt",
"condition": {
"operator": "notEmpty"
},
"severity": "error",
"remediation": "Add a short excerpt before publishing."
}

The trade-off is simple: the more precise the remediation, the more likely it is to help. The downside is that very specific messages can become stale if the editorial rule changes. Keep the message aligned with the rule, not with one person’s preference.

What is a practical schema example?

A practical schema example should show how the parts fit together in one record set, not just one rule. A small rules array is usually enough to show the pattern and make the structure reusable.

Here is a compact schema for 3 WordPress content checks:

json
{
"schemaVersion": "1.0",
"rules": [
{
"id": "title-length",
"name": "Title length",
"field": "post_title",
"condition": { "operator": "between", "min": 40, "max": 65 },
"severity": "warning",
"remediation": "Keep the title between 40 and 65 characters."
},
{
"id": "excerpt-required",
"name": "Excerpt present",
"field": "post_excerpt",
"condition": { "operator": "notEmpty" },
"severity": "error",
"remediation": "Add an excerpt before publishing."
},
{
"id": "body-length",
"name": "Body length",
"field": "post_content",
"condition": { "operator": "minWords", "value": 300 },
"severity": "error",
"remediation": "Add enough body copy to clear the minimum."
}
]
}

That example shows a pattern you can scale. A schemaVersion field gives you a place to change the format later without breaking old rules. The rules array keeps each rule independent, which makes it easier to sort, edit, and test.

A good schema is not trying to be a content strategy document. It is a record format. If the JSON starts carrying editorial policy, approval steps, and output formatting all at once, the schema becomes harder to maintain than the checks it was supposed to support.

The most practical next step is usually to align the schema with the rule stages already used elsewhere in the publishing system. This page sits under the broader validation rules by publishing stage hub, which is where stage-level structure belongs.

What makes a rule reusable?

A reusable rule uses generic field names, one condition, and a message that does not depend on one post. That lets the same rule work across templates, authors, or post types without rewriting it for each case.

Reusability starts with stable keys. An id like title-length works better than homepage-title-rule-3 because the first one says what the rule does, not where it happened to be created. The same idea applies to the field path. post_title is more reusable than a page-specific label like main headline.

A reusable rule also avoids hard-coding one threshold into the message if the threshold may change. If the minimum is 300 words today, the message should not say “Add 300 words”; it should say “Meet the minimum body length.” The exact number belongs in the condition, not buried in the text.

A few signs a rule is not reusable:

  • it names one author, one page, or one campaign
  • it combines 2 or more checks in one object
  • it uses a field path that only exists in one template
  • it puts the threshold in the message and nowhere else

That last point matters. A threshold belongs in the condition because that is the part code reads. If the value changes, the system should not need a rewrite of the message body.

A reusable schema is not always the right choice. If one rule only exists for a single landing page, a highly generic design may create more work than it saves. In that case, keep the schema simple and specific rather than forcing a reusable pattern that will never be used twice.

What fields should a rule schema include?

A rule schema should include at least id, name, field, condition, severity, and remediation. That set gives the rule a stable identity, a target, a test, a priority, and a human explanation. If the schema also needs versioning or scope, add those as separate fields instead of folding them into the condition.

How do you name validation rules?

A validation rule should be named for the thing it checks, not for the team that created it or the page where it first ran. “Title length” is clearer than “SEO rule 4,” and “Excerpt present” is clearer than “editorial requirement.” Short names also make rule lists easier to scan in a 10-second review.

What makes a rule reusable?

A reusable rule checks one thing, uses a stable field path, and keeps the threshold inside the condition rather than the message. It should work across posts, pages, or templates without changing the object shape. If a rule only makes sense for one page, reuse is not the goal; clarity is.

Drafted with AI; not yet reviewed by a person.

Leave a Reply

Your email address will not be published. Required fields are marked *