Schema-Woven Validation

Schema-Woven Validation (SWV) is the next generation of web form validation mechanism employed by Contact Form 7.

What problems does it solve?

In the early days of the World Wide Web, the roles of both the web form deliverer and form submission receiver were played by the same entity—the web server. The server naturally knew how it should treat the form input because the form was created by the server itself.

There was no problem until HTML5 introduced client-side form validation. Client-side validation allows a field value to validate promptly after the user inputs it. Although it can provide a good user experience, client-side validation doesn’t replace server-side validation. Form validation still must be run on the server side, but now there are two different entities who engage in form validation: web server and client (browser).

The spread of headless CMS or other types of decoupled architecture has further complicated the situation. In such architectures, it is not rare that there are multiple entities involved in web forms. And since there is no standardized method of form validation, the entities may not know the correct way to validate the form input. Schema-Woven Validation (SWV) solves this problem.

SWV provides a JSON-formatted schema language that defines the expected form of user input. With SWV, you can safely implement web forms without sacrificing the benefit gained from modern web architectures.

Example

This is an example SWV schema created for the default contact form.

{
    "version": "Contact Form 7 SWV Schema 2022-03",
    "locale": "en_US",
    "rules": [
        {
            "rule": "required",
            "field": "your-name",
            "error": "Please fill out this field."
        },
        {
            "rule": "required",
            "field": "your-email",
            "error": "Please fill out this field."
        },
        {
            "rule": "email",
            "field": "your-email",
            "error": "Please enter an email address."
        },
        {
            "rule": "required",
            "field": "your-subject",
            "error": "Please fill out this field."
        }
    ]
}

Supported rule types

See Predefined rule types.

Schema’s schema

See Meta schema.

Just another contact form plugin for WordPress. Simple but flexible.