$ show dry-rb/dry-schema
dry-schema is a Ruby library for data validation and schema definition, not an application or data pipeline. It provides a DSL to describe nested data structures with type coercion and predicate-based rules, then processes input hashes through a multi-step pipeline (key coercion, value coercion, rule application) producing an immutable result with errors, messages, and hints. It exposes Dry::Schema.define for plain schemas, Dry::Schema.Params for HTTP parameter coercion, and Dry::Schema.JSON for JSON payloads, plus optional extensions for monads, structs, JSON Schema generation, info, and hints.
The LLM identified 5 files worth highlighting for reuse:
Translates Dry::Schema rules into JSON Schema draft-06 using a visitor over the rule AST. It maps predicates such as filled?, size?, and included_in? to JSON Schema constraints and supports nested schemas, unions, and loose mode for unknown predicates. This is a non-trivial example of serializing a domain-specific validation DSL into a standard interop format.
Orders schema processing as a list of steps with before/after callbacks scoped to nested paths. This is the backbone of the coercion/validation pipeline and demonstrates an injectable step pipeline with path-aware hooks, a reusable abstraction for any multi-stage data-processing system.
Builds a map of input hash keys to canonical keys, handling string/symbol normalization, nesting, and aliasing with caching to avoid repeated recomputation. It is a self-contained utility useful for normalizing arbitrary nested hashes.
A value object representing nested paths in the input hash (e.g., [:address, :city]) with equality, comparison, intersection, and key-ability. Used by error handling and key traversal, it demonstrates a clean immutable value-object design for addressing nested structures.
Common message lookup engine for locale-aware error messages, building lookup paths from rule AST and metadata, resolving arguments and type information, and caching parsed templates. The backend abstraction allows YAML and I18n implementations to share consistent behavior and is a good model for a reusable message-catalog service.