All For One, And One For All: A Single Ruby on Rails Validator For All Controllers

Written by eti | Published 2019/11/24
Tech Story Tags: ruby | ruby-on-rails-development | validator | software-development | backend | hackernoon-top-story | ruby-on-rails | ruby-on-rails-validator | web-monetization

TLDR A good set of validations would spare you the need of investigating a hidden bug that causes ambiguous error messages or sends malformed data to a third party. ActiveSupport::Concern helped me solve this issue with ActiveModel::Validation. I wanted to find a generic super validator that you only need to implement once, and by including it to the validation-needed class, you would get all validations for free. The idea was simple; the only thing I had to overcome was finding out which attribute was defined for a specific class, which turned out to be kind of a tough problem.via the TL;DR App

no story

Written by eti | Engineering Manager, Software Engineer, Tech Enthusiastic, Blog writer, Mom, Superhero
Published by HackerNoon on 2019/11/24