// 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 Quantity = number & { readonly __brand: "Quantity" };

export const Quantity = {
  of(value: number): Result<Quantity, ValidationError> {
    if (!Number.isInteger(value)) {
      return Err({ field: "Quantity", message: "must be an integer", value });
    }
    if (!(value >= 1 && value <= 100)) {
      return Err({ field: "Quantity", message: "must be in range [1, 100]", value });
    }
    return Ok(value as Quantity);
  },
  unsafe(value: number): Quantity {
    return value as Quantity;
  },
};

