xrpl.js icon indicating copy to clipboard operation
xrpl.js copied to clipboard

Make validateRequiredField & validateOptionalField errors more specific

Open achowdhry-ripple opened this issue 11 months ago • 1 comments

In packages/xrpl/src/models/transactions/common.ts, we currently have two helper functions that are the standard for all transaction validate functions to use for each field. -validateRequiredField() -validateOptionalField()

However, the message is vague ("invalid field XXX", etc), and we would like to tailor the message to the exact type for better user experience and debugging. For example, "Invalid field XXX" should become "XXX must be a string", and the type can either be inferred by the checkValidity parameter of these helper methods or a new parameter can be added for the exact type to provide in the error messaging (there is flexibility with the exact formatting, can be "Expected type String, received type YYY", etc)

Conversation: https://github.com/XRPLF/xrpl.js/pull/2829/files#r1893062063

Noticed in https://github.com/XRPLF/xrpl.js/pull/2829

achowdhry-ripple avatar Dec 20 '24 19:12 achowdhry-ripple

@achowdhry-ripple @mvadari PR open and ready for review.

lacostenycoder avatar Apr 10 '25 14:04 lacostenycoder