UNPKG

@bit-gpt/h402

Version:

BitGPT's 402 open protocol for blockchain-native payments

26 lines 1.24 kB
import { type Money } from "../types"; /** * Parses a money input (string or number) into a validated number. * * - If the input is a string, it strips out all non-numeric characters * except digits, decimal points, and negative signs (e.g., "$1,234.56" → 1234.56). * - If the input is already a number, it is converted to a string and re-parsed. * - The resulting number must be between 0 and 999999999 (inclusive). * - Maximum of 4 decimal places allowed. * - Negative values are not allowed. * - Scientific notation is not allowed. * * @param {Money} input - A string or number representing a monetary value. * @returns {number} The cleaned and validated numeric value. * * @throws {Error} If the input is not a string or number. * @throws {Error} If the cleaned input cannot be parsed into a valid number. * @throws {Error} If the number is outside the accepted range. * @throws {Error} If the number has too many decimal places. * @throws {Error} If the number is negative. * @throws {Error} If the input contains multiple decimal points. * @throws {Error} If the input is in scientific notation. */ declare function parseMoney(input: Money): number; export { parseMoney }; //# sourceMappingURL=parseMoney.d.ts.map