I need to validate a form but I don't want to use validations from model, because fields come from many models.
I'd like to do something like request from Laravel https://laravel.com/docs/5.7/validation#creating-form-requests
You can use ActiveModel::Validations like this
class MyClass
include ActiveModel::Validations
validates :email, presence: true
validates :message, presence: true
end
It will act as a normal model.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.