Analysis updated 2026-07-03
Map incoming JSON API response data to a Ruby domain object with typed fields without writing manual conversion code
Sanitize and coerce web form parameters into the correct types before processing them in a Rails controller
Build a Ruby value object with a typed collection attribute such as an array of address objects with enforced types
| solnic/virtus | laserlemon/figaro | feedbin/feedbin | |
|---|---|---|---|
| Stars | 3,747 | 3,748 | 3,745 |
| Language | Ruby | Ruby | Ruby |
| Setup difficulty | easy | easy | hard |
| Complexity | 2/5 | 1/5 | 4/5 |
| Audience | developer | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
Project is discontinued, new projects should use dry-types and dry-struct instead as the author recommends.
Virtus is a Ruby library that lets you add typed attributes to plain Ruby objects. Normally, a Ruby class has no built-in way to say "this field should be an integer" or "this field should be a date" and have that enforced automatically. Virtus fills that gap by giving you a clean way to declare attributes with specific types, and it will automatically convert incoming values to match those types when possible. For example, if you define an attribute as an integer and someone passes in the string "31", Virtus converts it to the number 31 without you having to write any conversion code. The same logic applies to dates: pass in a date string and get back a proper date object. This is useful any time data arrives from outside your program, such as from a web form, a JSON response, or a configuration file. The library also supports default values, nested objects (where one attribute is itself another Virtus-backed object), and typed collections (an array of integers, or an array of address objects). You can control which features are active: constructor generation, mass assignment, and type coercion can each be turned on or off independently. The README prominently states that Virtus is discontinued. The author, having learned from building it, went on to create a set of successor libraries called dry-types, dry-struct, and dry-schema, which handle the same problems with a cleaner design. Anyone starting a new project is directed to those replacements instead. For projects that already use Virtus and have not yet migrated, the library still functions as documented. Its original use cases included sanitizing and coercing input parameters in web applications, mapping JSON data to domain objects, building value objects, and prototyping data models. The gem is available through the standard Ruby package registry.
Virtus is a discontinued Ruby library that adds typed, auto-coercing attributes to plain Ruby objects, converting strings to integers or dates automatically. The author now recommends dry-types as the modern replacement.
Mainly Ruby. The stack also includes Ruby.
Setup difficulty is rated easy, with roughly 30min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.