UNPKG

postchain-client

Version:

Client library for accessing a Postchain node through REST.

21 lines 781 B
import { BufferSchema } from "./bufferSchema"; import { InvalidTxRidException } from "../../restclient/errors"; export const TxRidSchema = BufferSchema.refine((x) => x.length === 32, "Rid must be 32 bytes long"); export const isTxRidValid = (rid, options) => { const TxRidValidationContext = TxRidSchema.safeParse(rid); const { throwOnError = false } = options || {}; const hasError = "error" in TxRidValidationContext; if (!hasError) { return { success: true }; } const validationError = new InvalidTxRidException(rid); if (throwOnError) { throw validationError; } return { success: false, error: TxRidValidationContext.error, message: validationError.message, }; }; //# sourceMappingURL=txRid.js.map