@ledgerhq/coin-ton
Version:
16 lines • 639 B
JavaScript
import { MAX_COMMENT_BYTES } from "../constants";
/**
* Validates a TON transaction comment (memo).
*
* Note: While this function is named `validateMemo` for consistency across
* coin modules, TON uses a "comment" instead.
* The validation checks multiple fields, not only text value.
*
* @param comment - TON comment object containing text and encryption flag
* @returns true if the comment is valid, false otherwise
*/
export function validateMemo(comment) {
return (comment.isEncrypted ||
(comment.text.length <= MAX_COMMENT_BYTES && /^[\x20-\x7F]*$/.test(comment.text)));
}
//# sourceMappingURL=validateMemo.js.map