paint-brush
All For One, And One For All: A Single Ruby on Rails Validator For All Controllers by@eti
1,082 reads
1,082 reads

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

by Eti Dahan Noked3mNovember 24th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

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.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - All For One, And One For All: A Single Ruby on Rails Validator For All Controllers
Eti Dahan Noked HackerNoon profile picture
Eti Dahan Noked

Eti Dahan Noked

@eti

Engineering Manager, Software Engineer, Tech Enthusiastic, Blog writer, Mom, Superhero

About @eti
LEARN MORE ABOUT @ETI'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Eti Dahan Noked HackerNoon profile picture
Eti Dahan Noked@eti
Engineering Manager, Software Engineer, Tech Enthusiastic, Blog writer, Mom, Superhero

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite