-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
Description
Basic Info
- rails_param Version: 0.11.1
- Ruby Version: 3.0.1
- Rails Version: 6.1.1
Issue description
I've been leveraging rails_params in one of prior projects. It works great however I prefer to keep controller neat. I wrote a chuck of code to extract validation rules to external files under some path e.g /app/validators/.../*._validator.rb. Validation file itself could look like:
module Api
module V1
class SessionsValidator
include RailsParam::Param
attr_reader :params
def initialize(params)
@params = params
end
def create
param! :username, String, required: true, blank: false
param! :password, String, required: true, blank: false
end
def refresh
param! :refresh_token, String, required: true, blank: false
end
end
end
endWhat do you think about such solution? If you find it as useful I could open a PR.