All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
validate function - Previously deprecated in v1.0.0, now completely removed
explain which provides cleaner semanticsexplain for validation (returns nil for valid, error map for invalid)(validate x) with (nil? (explain x)) or use explain directlyThis is a major refactoring that simplifies the API by removing the data-as-error pattern and introducing exception-based error handling for most operations. This release is NOT backward compatible with v0.1.0.
REMOVED: validate function → Use explain instead
(validate typeid) returned {:ok true} or {:error ...}(explain typeid) returns nil (valid) or error map (invalid)REMOVED: typeid->map function → Use parse instead
(typeid->map typeid) returned {:ok components} or {:error ...}(parse typeid) returns components map or throws ExceptionInfoRENAMED: generate function → Use create instead
{:error ...})MOVED: Codec functions to typeid.codec namespace
encode, decode, uuid->hex, hex->uuid now in typeid.codec (not typeid.core){:error ...}NEW: create function with three arities
(create) - Generate TypeID with no prefix(create prefix) - Generate TypeID with prefix(create prefix uuid) - Create TypeID from existing UUID (NEW functionality)All functions now use one of two patterns:
Validation pattern (explain): Returns nil for valid, error map for invalid
Exception pattern (parse, create, codec functions): Throws ExceptionInfo on invalid input
:type, :message, :input, and contextexplain function: Validation that returns nil for valid TypeIDs or detailed error map for invalid
validate function with cleaner semanticsparse function: Exception-based TypeID parsing
ExceptionInfo with structured error data on invalid input{:prefix, :suffix, :uuid, :typeid} for valid inputtypeid->map functioncreate function with 2-arity: Create TypeID from existing UUID
java.util.UUID on JVM, cljs.core/UUID on ClojureScript)typeid.codec namespace: Separate namespace for low-level operations
encode: UUID bytes + prefix → TypeID stringdecode: TypeID string → UUID bytesuuid->hex: UUID bytes → hex string (32 chars, lowercase)hex->uuid: Hex string → UUID bytes (accepts hyphens and uppercase)Error maps: Consistent structure across all functions
:type - Namespaced keyword (e.g., :typeid/invalid-prefix):message - Human-readable error description:input - Original input that caused the error:expected - Expected format/value (optional):actual - Actual problematic value (optional)Exception handling: Functions use ex-info with structured data
(ex-data e)Documentation: Complete rewrite of README and API docs
explain, parse, and createSee the Migration Guide in the README for detailed migration instructions.
Quick migration checklist:
validate with explain and update error handlingtypeid->map with parse and add exception handlinggenerate to create (API is compatible for 0-arity and 1-arity)typeid.codec namespacecreate (2-arity) for UUID encoding use cases{:ok ...} / {:error ...} pattern to exception handlingtypeid.core) and 4 codec functions (typeid.codec)Core API: Complete TypeID generation, parsing, validation, and conversion
generate - Generate new TypeIDs with optional prefixesparse - Parse TypeID strings into componentsvalidate - Validate TypeID format and constraintsencode - Convert UUID bytes to TypeIDdecode - Extract UUID bytes from TypeIDuuid->hex / hex->uuid - UUID format conversiontypeid->map - Extract all TypeID components as a mapCross-platform support: Identical API for Clojure JVM and ClojureScript
System.currentTimeMillis() and SecureRandomjs/Date.now() and crypto.getRandomValues()Performance optimizations: Sub-microsecond operations
Comprehensive validation:
:type, :message, and :dataTesting infrastructure:
80% code coverage (100% for critical paths)
Documentation:
Build and tooling:
generate: < 2μs per operationparse: < 2μs per operationencode/decode: < 1μs per operationvalidate-prefix: < 500ns per operationCan you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |