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

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

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

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

export type CustomerId = string & { readonly __brand: "CustomerId" };

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

