{"id":"cross-field-rules","title":"Check caller-declared rules across fields of a JSON record: end after start, conditional required, exactly one of","description":"Evaluates up to 100 rules you declare over one JSON document and reports, per rule, pass, fail or unknown with the JSON pointer of every violating field and the actual value class (absent, null, empty string, value). Rule kinds: compare (>, >=, <, <=, ==, != on numbers, exact decimals, RFC 3339 dates or date-times, strings), required-if, forbidden-if, exactly-one, at-most-one, at-least-one, all-or-none, sum-equals (exact decimal sum with tolerance). A * path segment applies the rule to every array element (/lines/*/end > /lines/*/start). Presence is explicit (defined, non-null, non-empty) so absent, null and empty are never conflated. A missing operand yields unknown unless you choose fail or skip. For agents validating tool arguments or records beyond what a per-field schema can say. Rules are data, not code: no expressions are evaluated.","roi":"Per-field schemas cannot say end > start or one-of-three. 100 rules per $0.005 call, exact decimals and strict date parsing.","audience":"developer","package":"data-contract-kit","channels":["x402","mcp"],"endpoint":{"method":"POST","url":"https://agents.writerslogic.com/api/v1/cross-field-rules","path":"/api/v1/cross-field-rules","contentType":"application/json"},"price":{"amount":"0.005","currency":"USDC","network":"base","perCall":true,"failedCallsCharged":false},"inputSchema":{"type":"object","additionalProperties":false,"required":["data","rules"],"properties":{"data":{"description":"The JSON document the rules apply to."},"rules":{"type":"array","minItems":1,"maxItems":100,"items":{"type":"object","additionalProperties":false,"required":["id","kind"],"properties":{"id":{"type":"string","maxLength":80},"kind":{"type":"string","enum":["compare","required-if","forbidden-if","exactly-one","at-most-one","at-least-one","all-or-none","sum-equals"]},"left":{"type":"string","maxLength":300,"description":"JSON pointer; * matches every array element."},"op":{"type":"string","enum":["==","!=",">",">=","<","<="]},"right":{"type":"string","maxLength":300,"description":"JSON pointer compared with left (use value for a constant)."},"value":{"description":"Constant to compare with, or the expected total."},"as":{"type":"string","enum":["auto","number","decimal","date","datetime","string"]},"when":{"type":"object","additionalProperties":false,"required":["path","op"],"properties":{"path":{"type":"string","maxLength":300},"op":{"type":"string","enum":["equals","not-equals","in","not-in","present","absent","empty"]},"value":{"description":"Operand for equals, not-equals, in, not-in."}}},"require":{"type":"array","maxItems":20,"items":{"type":"string","maxLength":300}},"forbid":{"type":"array","maxItems":20,"items":{"type":"string","maxLength":300}},"fields":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":300}},"total":{"type":"string","maxLength":300},"tolerance":{"type":"string","maxLength":40,"description":"Decimal tolerance for sum-equals, default 0."},"presence":{"type":"string","enum":["defined","non-null","non-empty"],"description":"What counts as present: defined (key exists), non-null (default), non-empty."}}}},"onMissing":{"type":"string","enum":["unknown","fail","skip"],"description":"Missing or null compare operand: unknown (default), fail or skip."}}},"resultSchema":{"type":"object","properties":{"status":{"type":"string","enum":["pass","fail","unknown","unsupported"],"description":"pass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass."},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"verdict":{"type":"string","enum":["pass","fail","unknown"]},"evaluations":{"type":"integer"},"violations":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"detail":{"type":"string"},"actual":{"description":"Value or value class found."}}}}}}},"counts":{"type":"object","properties":{"pass":{"type":"integer"},"fail":{"type":"integer"},"unknown":{"type":"integer"}}},"witnesses":{"type":"array","items":{"type":"object","properties":{"ruleId":{"type":"string"},"detail":{"type":"string"},"path":{"type":"string","description":"JSON pointer or dotted path into the input."},"offset":{"type":"integer"},"index":{"type":"integer"},"expected":{"description":"What the rule required."},"actual":{"description":"What the input had."}}}},"versions":{"type":"object","description":"Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile)."},"limits":{"type":"array","items":{"type":"string"}},"deterministic":{"type":"boolean","description":"Always true: pure code, no model."}}},"outputSchema":{"type":"object","properties":{"data":{"type":"object","properties":{"status":{"type":"string","enum":["pass","fail","unknown","unsupported"],"description":"pass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass."},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"verdict":{"type":"string","enum":["pass","fail","unknown"]},"evaluations":{"type":"integer"},"violations":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"detail":{"type":"string"},"actual":{"description":"Value or value class found."}}}}}}},"counts":{"type":"object","properties":{"pass":{"type":"integer"},"fail":{"type":"integer"},"unknown":{"type":"integer"}}},"witnesses":{"type":"array","items":{"type":"object","properties":{"ruleId":{"type":"string"},"detail":{"type":"string"},"path":{"type":"string","description":"JSON pointer or dotted path into the input."},"offset":{"type":"integer"},"index":{"type":"integer"},"expected":{"description":"What the rule required."},"actual":{"description":"What the input had."}}}},"versions":{"type":"object","description":"Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile)."},"limits":{"type":"array","items":{"type":"string"}},"deterministic":{"type":"boolean","description":"Always true: pure code, no model."}}},"_provenance":{"type":"object","description":"C2PA-aligned manifest and W3C VC 2.0 (eddsa-jcs-2022) issued by the hub DID; verify at POST /api/v1/verify-provenance"}},"required":["data","_provenance"]},"example":{"data":{"start":"2026-03-01","end":"2026-02-01","kind":"card","card":"4111","iban":null},"rules":[{"id":"end-after-start","kind":"compare","left":"/end","op":">","right":"/start","as":"date"},{"id":"card-needs-number","kind":"required-if","when":{"path":"/kind","op":"equals","value":"card"},"require":["/card"]},{"id":"one-payment-method","kind":"exactly-one","fields":["/card","/iban"]}]},"openapiOperation":{"operationId":"cross_field_rules","summary":"Check caller-declared rules across fields of a JSON record: end after start, conditional required, exactly one of","description":"Evaluates up to 100 rules you declare over one JSON document and reports, per rule, pass, fail or unknown with the JSON pointer of every violating field and the actual value class (absent, null, empty string, value). Rule kinds: compare (>, >=, <, <=, ==, != on numbers, exact decimals, RFC 3339 dates or date-times, strings), required-if, forbidden-if, exactly-one, at-most-one, at-least-one, all-or-none, sum-equals (exact decimal sum with tolerance). A * path segment applies the rule to every array element (/lines/*/end > /lines/*/start). Presence is explicit (defined, non-null, non-empty) so absent, null and empty are never conflated. A missing operand yields unknown unless you choose fail or skip. For agents validating tool arguments or records beyond what a per-field schema can say. Rules are data, not code: no expressions are evaluated.\n\nPrice: 0.005 USDC on Base (x402).","x-x402-price-usdc":"0.005","x-x402-amount":"5000","x-payment-info":{"protocols":["x402"],"price":{"mode":"fixed","currency":"USD","amount":"0.005"}},"x-audience":"developer","x-sample-url":"https://agents.writerslogic.com/api/v1/samples/cross-field-rules","security":[{"x402":[]},{"apiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["data","rules"],"properties":{"data":{"description":"The JSON document the rules apply to."},"rules":{"type":"array","minItems":1,"maxItems":100,"items":{"type":"object","additionalProperties":false,"required":["id","kind"],"properties":{"id":{"type":"string","maxLength":80},"kind":{"type":"string","enum":["compare","required-if","forbidden-if","exactly-one","at-most-one","at-least-one","all-or-none","sum-equals"]},"left":{"type":"string","maxLength":300,"description":"JSON pointer; * matches every array element."},"op":{"type":"string","enum":["==","!=",">",">=","<","<="]},"right":{"type":"string","maxLength":300,"description":"JSON pointer compared with left (use value for a constant)."},"value":{"description":"Constant to compare with, or the expected total."},"as":{"type":"string","enum":["auto","number","decimal","date","datetime","string"]},"when":{"type":"object","additionalProperties":false,"required":["path","op"],"properties":{"path":{"type":"string","maxLength":300},"op":{"type":"string","enum":["equals","not-equals","in","not-in","present","absent","empty"]},"value":{"description":"Operand for equals, not-equals, in, not-in."}}},"require":{"type":"array","maxItems":20,"items":{"type":"string","maxLength":300}},"forbid":{"type":"array","maxItems":20,"items":{"type":"string","maxLength":300}},"fields":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":300}},"total":{"type":"string","maxLength":300},"tolerance":{"type":"string","maxLength":40,"description":"Decimal tolerance for sum-equals, default 0."},"presence":{"type":"string","enum":["defined","non-null","non-empty"],"description":"What counts as present: defined (key exists), non-null (default), non-empty."}}}},"onMissing":{"type":"string","enum":["unknown","fail","skip"],"description":"Missing or null compare operand: unknown (default), fail or skip."}}},"example":{"data":{"start":"2026-03-01","end":"2026-02-01","kind":"card","card":"4111","iban":null},"rules":[{"id":"end-after-start","kind":"compare","left":"/end","op":">","right":"/start","as":"date"},{"id":"card-needs-number","kind":"required-if","when":{"path":"/kind","op":"equals","value":"card"},"require":["/card"]},{"id":"one-payment-method","kind":"exactly-one","fields":["/card","/iban"]}]}}}},"responses":{"200":{"description":"Paid result with provenance","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"status":{"type":"string","enum":["pass","fail","unknown","unsupported"],"description":"pass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass."},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"verdict":{"type":"string","enum":["pass","fail","unknown"]},"evaluations":{"type":"integer"},"violations":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"detail":{"type":"string"},"actual":{"description":"Value or value class found."}}}}}}},"counts":{"type":"object","properties":{"pass":{"type":"integer"},"fail":{"type":"integer"},"unknown":{"type":"integer"}}},"witnesses":{"type":"array","items":{"type":"object","properties":{"ruleId":{"type":"string"},"detail":{"type":"string"},"path":{"type":"string","description":"JSON pointer or dotted path into the input."},"offset":{"type":"integer"},"index":{"type":"integer"},"expected":{"description":"What the rule required."},"actual":{"description":"What the input had."}}}},"versions":{"type":"object","description":"Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile)."},"limits":{"type":"array","items":{"type":"string"}},"deterministic":{"type":"boolean","description":"Always true: pure code, no model."}}},"_provenance":{"type":"object","description":"C2PA-aligned manifest and W3C VC 2.0 (eddsa-jcs-2022) issued by the hub DID; verify at POST /api/v1/verify-provenance"}},"required":["data","_provenance"]}}}},"400":{"description":"Invalid request (no payment consumed)","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}}}}}},"401":{"description":"Invalid X-API-KEY","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}}}}}},"402":{"description":"Payment required or invalid","content":{"application/json":{"schema":{"type":"object","description":"x402 v2 PaymentRequired (also base64 in the PAYMENT-REQUIRED header)","properties":{"x402Version":{"type":"integer"},"error":{"type":"string"},"code":{"type":"string"},"resource":{"type":"object"},"accepts":{"type":"array","items":{"type":"object"}},"extensions":{"type":"object"}}}}}},"502":{"description":"Upstream failure; the payment is released or not settled","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}}}}}}}},"links":{"docs":"https://agents.writerslogic.com/docs/cross-field-rules/","docsJson":"https://agents.writerslogic.com/docs/cross-field-rules.json","sample":"https://agents.writerslogic.com/api/v1/samples/cross-field-rules","openapi":"https://agents.writerslogic.com/openapi.json","catalog":"https://agents.writerslogic.com/api/v1/catalog","verifyProvenance":"https://agents.writerslogic.com/api/v1/verify-provenance","index":"https://agents.writerslogic.com/docs/index.json"}}