How to build reusable validations in Ruby on Rails
975 بار بازدید -
3 سال پیش
-
You can build some super
You can build some super reusable validations by extending the ActiveModel::EachValidator class. Here is a very quick run through on how to do that :)
Sources
➡ https://api.rubyonrails.org/classes/A...
➡ https://github.com/MikeRogers0-YouTub...
Chapters
0:00 - What are we going to do
0:30 - Custom Validations
2:21 - What arguments are available to validate_each
4:53 - Testing with RSpec
7:10 - Our first RSpec test
10:40 - 100% code coverage
11:23 - Why do we need attributes: { any: true } ?
11:09 - Thank you
Follow Me Online
➡ Blog: https://mikerogers.io/
➡ Twitter: Twitter: MikeRogers0
➡ GitHub: https://github.com/mikerogers0
➡ YouTube: mikerogers0
➡ BuyMeACoffee: https://www.buymeacoffee.com/MikeRogers0
➡ Dev.to: https://dev.to/mikerogers0
#RubyOnRails #RSpec #Validation
Sources
➡ https://api.rubyonrails.org/classes/A...
➡ https://github.com/MikeRogers0-YouTub...
Chapters
0:00 - What are we going to do
0:30 - Custom Validations
2:21 - What arguments are available to validate_each
4:53 - Testing with RSpec
7:10 - Our first RSpec test
10:40 - 100% code coverage
11:23 - Why do we need attributes: { any: true } ?
11:09 - Thank you
Follow Me Online
➡ Blog: https://mikerogers.io/
➡ Twitter: Twitter: MikeRogers0
➡ GitHub: https://github.com/mikerogers0
➡ YouTube: mikerogers0
➡ BuyMeACoffee: https://www.buymeacoffee.com/MikeRogers0
➡ Dev.to: https://dev.to/mikerogers0
#RubyOnRails #RSpec #Validation
3 سال پیش
در تاریخ 1400/05/19 منتشر شده
است.
975
بـار بازدید شده