AI summary not available
This video doesn't have a transcript yet
Transcript not available
This video doesn't have captions
Start a conversation
Ask anything about RailsConf 2025 Off the Rails: Validating non-model classes with…ActiveModel? by Andy Andrea
AI responses may be inaccurate. Verify important information.
RailsConf 2025 Off the Rails: Validating non-model classes with…ActiveModel? by Andy Andrea
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.