// Generated by bynkc — do not edit by hand.
// commons shortener.analytics

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

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

export const ShortCode = {
  of(value: string): Result<ShortCode, ValidationError> {
    if (!(value.length >= 3)) {
      return Err({ field: "ShortCode", message: "length must be at least 3", value });
    }
    if (!(value.length <= 16)) {
      return Err({ field: "ShortCode", message: "length must be at most 16", value });
    }
    return Ok(value as ShortCode);
  },
  unsafe(value: string): ShortCode {
    return value as ShortCode;
  },
  fromString(s: string): Result<ShortCode, ValidationError> {
    return ShortCode.of(s);
  },
};

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

export const LongUrl = {
  of(value: string): Result<LongUrl, ValidationError> {
    if (!(value.length >= 1)) {
      return Err({ field: "LongUrl", message: "length must be at least 1", value });
    }
    if (!(value.length <= 2048)) {
      return Err({ field: "LongUrl", message: "length must be at most 2048", value });
    }
    return Ok(value as LongUrl);
  },
  unsafe(value: string): LongUrl {
    return value as LongUrl;
  },
  fromString(s: string): Result<LongUrl, ValidationError> {
    return LongUrl.of(s);
  },
};

