Why a correct structure is insufficient

A JSON response can contain every required field and still describe a contradictory order. For example, one field selects a standard product while adjacent fields also request custom manufacturing. Before further processing, check which combinations of values are allowed for each variant.

Separate this check from syntax validation. MDN documents JSON parsing errors, including unterminated strings and trailing commas. Successful parsing makes the data readable, but does not check your ordering rules.

Google likewise recommends validating structured output values in the application: a response can match its schema and contain semantic errors. Our method produces a separate set of conditions that the receiving system uses to accept a record, reject it, or refer it to a person.

Define the permitted combinations

Consider a fictional order for a protective insert for a drawing compass case. Two variants are available: standard, selected by code, and custom, specified by dimensions. Our example record contains mode, standard_code, custom_width_mm, and custom_height_mm. These field names belong to the example. All four fields are always present.

For standard mode, standard_code must be nonempty and both custom dimension fields must contain null. For custom mode, the code must contain null, while width and height must be positive integers in millimeters. The process owner establishes these rules in advance; the model receives them with the task.

For example, the source instruction says: “Order a standard P2 insert, without custom manufacturing.” An acceptable record contains standard, P2, and two null values. A deliberately incorrect example with the same first two fields and dimensions of 180 and 120 violates the standard order rule, although each value looks plausible individually.

Separate the schema from combination checks

A basic schema might require every field, restrict mode options, and allow either numbers or null. Without a defined relationship between fields, it permits a contradictory record. The official JSON Schema guide explains how if, then, and else apply different requirements depending on a condition.

Another construct, dependentRequired, makes the presence of one field require another field. This dependency is directional. In our record, every field is already mandatory, so presence checks alone are insufficient: values and the selected mode need checking. Explain these distinctions to the developer implementing validation.

The generator and receiving application may support different validation features. Google documents support for a subset of JSON Schema in structured output mode. Check whether your selected model supports the constructs you need. Keep the complete ordering rules for validating received results, even when generation uses a simpler schema.

Test the rules using prepared records

Prepare two valid example records. The first contains standard, code P2, and two null dimensions. The second contains custom, a null code, width 180, and height 120. Both should pass. You can check these prepared records manually or through the receiving application, without another model call.

Next, create separate incorrect copies. Add dimensions to the standard record. Add code P2 to the custom record. In further custom copies, replace the width first with null and then with zero. Finally, give the standard record an empty code string. Record the specific violated rule for each copy in advance.

All five incorrect copies should be rejected with an understandable reason. Also remove mode: that version should fail structural validation. If the system accepts an error or rejects a valid record, fix validation first. Retain these records for checks after changes to rules or processing settings.

Check an actual response before handoff

For a received response, check parsing, basic schema compliance, and permitted field combinations in sequence. Record the outcomes separately. “JSON is valid” is too broad: it does not show whether validation covered syntax alone or also the selected order branch and its restrictions.

When validation fails, retain the original record and identify the conflicting fields. For example: “Standard mode requires no custom dimensions; custom_width_mm contains 180.” This makes the correction verifiable. A general request to “produce correct JSON” leaves the specific error and the values to preserve unclear.

After correction, repeat every check and compare values with the source instruction. A record containing custom, a null code, and dimensions of 180 by 120 may pass internal validation. However, it remains incorrect for an instruction requesting standard P2. Check internal consistency and source agreement separately.

Account for SeaGenera capabilities and limitations

SeaGenera documentation states that json_schema requires the selected model to support response_format and structured_outputs. Check these capabilities before requesting generation. Apply the proposed combination checks when accepting the result: structured output mode alone does not confirm compliance with every rule in your process.

SeaGenera documentation also states that personal data masking is incompatible with json_object and json_schema. A key with mandatory masking rejects that combination before generation. Account for this limitation when preparing the workflow, and use fictional information in example records that requires no restoration of personal data.

This method detects only contradictions described in advance. It does not confirm that code P2 exists, the product is available, or the dimensions fit the case. Those questions require separate evidence and checks. If the source cannot establish an order variant, refer the record for clarification, retaining the instruction and the reason processing stopped.

Sources