RailsConf 2025 Off the Rails: Validating non-model classes with…ActiveModel? by Andy Andrea - YouTube
02-Aug-2025 36
Have you ever wished you could run Rails validators to check that a Hash, Struct or Data instance is properly formatted? Have you ever wanted to be able to compose complex validation logic on the fly rather than registering them at a class level with complicated conditionals? Did you ever have a use case for a single, generic validation and thought it’d be overkill to create a new ActiveModel class?
In this talk, we'll explore how to build a single class that’ll accept almost any kind of argument and let you register and run both built-in and custom validations against that argument’s key/value pairs and methods. Through test-driven development and examining the source code for ActiveModel validations and ActiveSupport callbacks, we’ll gradually build a robust solution to support custom and built-in validators and their various options like `if` and `allow_blank`.
Whether you want to validate a JSON field in a model, ensure that an incoming API request is properly formatted, check for valid events in an event-sourced application or run a validator against a class from a third-party library without monkey-patching, this talk will help you use some of Rails’ most classic features in a new and powerful way.
RailsConf 2025 Off the Rails: Validating non-model classes with…ActiveModel? by Andy Andrea - YouTube #ruby #rubydeveloper #rubyonrails #RailsConf #Rails: #Validating #non-model #classes #with…ActiveModel? #Andrea #YouTube #classes #youtube https://rubyonrails.ba/link/railsconf-2025-off-the-rails-validating-non-model-classes-with-activemodel-by-andy-andrea-youtube