Enhancing Debugging with Custom Error Messages in Schema Validation

Given a schema like this:
export const _Order = S.struct({
  id: OrderId,
  name: OrderName,
  totalPrice: NonNegativeMonetaryAmount,
  currency: ISO4217CurrencyCode,
  totalDiscounts: NonNegativeMonetaryAmount,
  createdAt: PastOrPresentDate,
  sourceName: S.nullable(S.union(KnownOrderSourceName, S.string)),
  transactions: S.array(Transaction),
  lineItems: S.array(LineItem),
  shippingLines: S.array(ShippingLine),
  discountApplications: S.array(DiscountApplication),
}).pipe(S.identifier("Order"), S.brand("Order"));


I ended up with an error like (image above). Which is really cool.
What would help even more in the debug process, is if we were able to pass in the error message the id or something, that would help to determine which model caused the issue)

I only saw the ast message annotation in the message or filter function so I am not sure what I ask for is even possible ?
image.png
Was this page helpful?