// Generated by bynkc — do not edit by hand.
// commons demo

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

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

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

