// Generated by bynkc — do not edit by hand.
// commons commerce.money

import { Ok, Err, Some, None, type Result, type Option, type ValidationError } from "../runtime.js";

export type Money = number & { readonly __brand: "Money" };

export const Money = {
  of(value: number): Result<Money, ValidationError> {
    if (!Number.isInteger(value)) {
      return Err({ field: "Money", message: "must be an integer", value });
    }
    if (!(value >= 0)) {
      return Err({ field: "Money", message: "must be non-negative", value });
    }
    return Ok(value as Money);
  },
  unsafe(value: number): Money {
    return value as Money;
  },
  fromMinorUnits(n: number): Result<Money, ValidationError> {
    return Money.of(n);
  },
};

