// Generated by bynkc — do not edit by hand.
// context commerce.orders

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

export type OrderId = string & { readonly __brand: "commerce.orders.OrderId" };

export const OrderId = {
  of(value: string): Result<OrderId, ValidationError> {
    if (!new RegExp("^" + "ORD-[0-9]+" + "$").test(value)) {
      return Err({ field: "OrderId", message: "must match /ORD-[0-9]+/", value });
    }
    return Ok(value as OrderId);
  },
  unsafe(value: string): OrderId {
    return value as OrderId;
  },
};

export type OrderError =
    { readonly tag: "EmptyCart" }
  | { readonly tag: "InvalidQuantity" };

export const OrderError = {
  EmptyCart: { tag: "EmptyCart" } as OrderError,
  InvalidQuantity: { tag: "InvalidQuantity" } as OrderError,
};

