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

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

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

export const Count = {
  of(value: number): Result<Count, ValidationError> {
    if (!Number.isInteger(value)) {
      return Err({ field: "Count", message: "must be an integer", value });
    }
    if (!(value >= 0)) {
      return Err({ field: "Count", message: "must be non-negative", value });
    }
    return Ok(value as Count);
  },
  unsafe(value: number): Count {
    return value as Count;
  },
  successor(self: Count): Result<Count, ValidationError> {
    return Count.of(self + 1);
  },
};

