verifyFields
import { verifyFields } from '@rudra-js/attested';Call verifyFields to check every field on a card in one call, including a claim that only shows when the fields are read together.
verifyFields(fields: Record<string, string>, facts: Facts) => BatchResultReference
verifyFields(fields, facts)
Parameters
fields: The card's text, keyed by field name, such as{ headline, badge, body }.facts: The same factsverifytakes.
Returns
A BatchResult. fields holds one { field, result } per field, in the order you gave them. Each result is what verify returns for that field. acrossFields is the wording check run over every field joined into one text. supported is true only when every field passes and acrossFields passes too.
Caveats
acrossFieldscatches a claim split between fields. A badge of "Free" and a body of "delivery on every order" each pass alone. The shopper reads them as one sentence, soacrossFieldsreports "free delivery".acrossFieldsruns only the wording check. Numbers are checked field by field.
Usage
Checking every field on a card at once
Pass the whole card, and show it only when supported is true.
import { verifyFields } from '@rudra-js/attested';
type Card = { headline: string; badge: string; body: string };
export function checkedCard(card: Card, price: number): Card | null {
const result = verifyFields(card, { values: [price] });
if (result.supported) return card;
const failed = result.fields
.filter((entry) => !entry.result.supported)
.map((entry) => entry.field);
console.warn('dropped a card', failed, result.acrossFields.findings);
return null;
}A badge of "Only 2 left" fails in fields, because nothing you supplied holds a 2. A claim split between fields shows only in acrossFields.
When anything fails, the sample drops the whole card and logs which fields failed.