function validatePrice
validatePrice(
raw: string,
minPrice: number,
maxPrice: number,
): PriceResult

Validate and convert a raw price string to minor units. Returns ok with 0 if raw is empty and minPrice is 0 (pay-what-you-want with no input). Returns error if raw is empty and minPrice > 0, or if parsed value is out of range.

Parameters

raw: string
minPrice: number
maxPrice: number

Return Type

Usage

import { validatePrice } from "docs/utilities.ts";