Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
c45e51fcb6
* Code formatting * Both "type" and "name" are used to refer to the validation type. Changed all to "type". * Added proper abstraction of realtime validation classes on server * UI improvements in admin and wizard
18 Zeilen
646 B
Ruby
18 Zeilen
646 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CustomWizard::RealtimeValidationsController < ::ApplicationController
|
|
def validate
|
|
klass_str = "CustomWizard::RealtimeValidation::#{validation_params[:type].camelize}"
|
|
result = klass_str.constantize.new(current_user).perform(validation_params)
|
|
render_serialized(result.items, "#{klass_str}Serializer".constantize, result.serializer_opts)
|
|
end
|
|
|
|
private
|
|
|
|
def validation_params
|
|
params.require(:type)
|
|
settings = ::CustomWizard::RealtimeValidation.types[params[:type].to_sym]
|
|
params.require(settings[:required_params]) if settings[:required_params].present?
|
|
params
|
|
end
|
|
end
|