
A Contact Form 7 integration can receive a technically valid HTTP request that still contains unusable lead data. A renamed field, a string where an array was expected or an omitted subscription choice can change the meaning of the record. A receiving adapter needs an explicit data contract before it writes to a CRM, spreadsheet or queue.
Ajv, Zod, Joi, Yup and Valibot are five validation libraries a developer can use in that receiving code. This comparison uses official documentation and license files checked October 18, 2026. It does not report a hands-on benchmark or claim that these libraries are WordPress plugins or native CF7 connectors.
Define the adapter boundary first
CF7’s browser submission and your chosen webhook connector are separate interfaces. A connector or custom adapter determines the outgoing payload. Inspect that exact shape rather than assume every CF7 integration sends the same JSON object. The selected library belongs in compatible JavaScript or TypeScript code you maintain; it does not replace CF7’s own input validation.
For this decision, imagine an adapter receiving a fictional inquiry with a form identifier, service, message and optional subscription flag. Decide which fields are required, which values may be absent, whether unknown properties should be rejected and whether conversion is allowed. Authentication, request-size limits, duplicate handling and destination authorization remain separate responsibilities.
Five-library decision table
| Library | Best fit | Useful strength | Main tradeoff |
|---|---|---|---|
| Ajv | Shared JSON Schema contracts | Compile and reuse schema validators | Schema dialect and mutation settings need ownership |
| Zod | TypeScript application adapters | Runtime schemas with inferred types | Input and transformed output may differ |
| Joi | Existing JavaScript service validation | Rich object rules and validation preferences | Conversion and unknown-field behavior need explicit choices |
| Yup | Projects already using schema parsing | Transforms and validation in one schema model | Casting must match the ingestion contract |
| Valibot | Modular TypeScript validation | Composable functions and typed outputs | Composition style and bundle fit require evaluation |
Ajv
Ajv is a natural shortlist entry when the integration contract is maintained as JSON Schema and needs to be shared with other services. Its getting-started guide describes compiling a schema into a validation function and reusing that function. Keeping schema construction outside the per-request path also gives the team a distinct artifact to review.
Strength: a schema can describe the receiving boundary independently of a particular application’s TypeScript types. Limitation: the chosen schema dialect, format support and validator options are part of the contract. A schema accepted by one configuration should not be assumed to behave identically in every validator or version.
Ajv offers optional removal of extra properties, default assignment and type coercion. Those settings can change data during validation, and its documentation identifies them as nonstandard behavior. For a lead adapter, decide whether an unfamiliar service should be rejected, retained or normalized before enabling convenient transformations. The project is MIT-licensed; operating the receiving service and maintaining its schema still have costs.
Zod
Zod is a TypeScript-first library that connects executable runtime schemas with inferred types. It fits an application where the developer wants the validated inquiry type to follow the schema rather than maintain a separate handwritten interface. The current documentation covers the stable Zod 4 family, including parsing and error-handling choices.
Strength: the boundary between unknown input and application data can be made visible in code review. Limitation: a static type by itself does not validate an HTTP body. The adapter must actually parse the untrusted value and handle failure before passing it to a destination client.
Review transformations and refinements with the receiving team. If the output differs from the original input, preserve enough context to explain what changed without logging the full private message. Check asynchronous rules and the project’s schema-export requirements rather than assume every custom rule translates to another format. Zod is MIT-licensed; no paid service subscription is required merely to use the library.
Joi
Joi provides an expressive schema language for JavaScript object validation. It deserves attention when a receiving service already uses Joi and the team can extend existing validation conventions consistently. Its API documents validation preferences, conversion, unknown values and structured error information.
Strength: a team can describe field relationships and reusable object rules within one familiar service layer. Limitation: defaults and preferences can affect interpretation. For example, accepting a value after conversion is a different contract from accepting only the incoming type. Review that choice for form identifiers, counts and boolean-like fields.
Ask a maintainer to show how an invalid inquiry is represented to the caller and to operations staff. Avoid returning private field values or detailed internals in a public error response. The current repository carries a BSD-style three-clause license, unlike the MIT licenses of the other libraries here. Review the license file for the pinned dependency and preserve required notices in your distribution process.
Yup
Yup combines schema parsing, transformations and validation. It can be a practical choice when the application already uses it for forms or other data boundaries and the developer wants consistent conventions in a receiving adapter. Its repository documentation distinguishes casting from validation and describes strict validation behavior.
Strength: explicit transformations can make a documented normalization step reusable. Limitation: a transformation that is convenient in an interactive interface may be inappropriate for an ingestion endpoint. Silently turning malformed input into a plausible value can hide a broken field mapping.
Specify whether the service should trim harmless whitespace, reject unknown properties or accept an optional field as missing. Then verify those decisions with examples from the actual connector contract. Do not use a default to manufacture a subscription choice or other decision the visitor did not make. Yup is MIT-licensed. Its reuse can reduce conceptual overhead, but only when the existing parsing conventions fit the receiving boundary.
Valibot
Valibot uses a modular function-based design for schema validation and transformations, with TypeScript inference. It offers parsing, a non-exception-based safe parsing path and composable validation actions. The design may appeal to developers who prefer selecting small functions rather than chaining many methods on a schema object.
Strength: composition can keep the rules for one adapter easy to isolate and review. Limitation: advertised bundle-size advantages are not measured results for your application. A server-only webhook receiver and browser-delivered code have different packaging priorities; evaluate the actual dependency graph where it will run.
Have the maintainer demonstrate required fields, unknown properties, optional values and the error format using the proposed pipeline. Confirm that transformations preserve the distinction between omitted and explicitly false subscription data. Valibot is MIT-licensed. It fits a team willing to adopt its function-oriented style and document that style for the next developer, rather than choose it solely because of a general size claim.
Evaluate the same contract in every candidate
Create a small set of synthetic payloads before selecting a library. Include a complete inquiry, a missing required service, a blank string, a null, an unexpected property, an array replacing a string and an omitted subscription flag. Define expected outcomes first. This is a proposed evaluation, not a published set of test results or a claim that one product detects more problems.
Decide how failure affects processing. An invalid body should not partially create a destination record before validation finishes. Distinguish a correct rejection from an infrastructure outage so a queue does not retry a permanently invalid record forever. Keep validation errors useful but redact private message content. Record schema version and adapter revision with the processing result.
Compare maintenance alongside license price. All five provide open-source libraries rather than a required per-submission hosted plan. Costs still include developer time, dependency updates, hosting and incident investigation. If the destination needs a standard schema shared across languages, prioritize that requirement. If a single TypeScript service owns the whole adapter, prioritize readable runtime boundaries and predictable error handling.
Choose by the receiving architecture
Shortlist Ajv for a JSON Schema contract, Zod for a TypeScript application boundary and Joi for an established JavaScript service. Consider Yup when its parsing model already fits the project, and Valibot when modular composition suits the team. A consistent, reviewed contract is more valuable than adding another validator without specifying its options.
Use our webhook testing comparison to inspect transport separately. Svetlik Analytics for Contact Form 7, our free plugin, provides submission statistics; it is separate from these receiving libraries and does not certify downstream payload validity. Our analytics guide explains the reporting boundary.
