title: Rails controller params validation by dry-validation
body: <p>First time I'am trying using dry validation gem.</p>
  
  <p>I want to create a form for multi-models (User, Address, Company)</p>
  
  <p>I decided to use a dry validator but I can't validate the form. I receive validator error ":user=>["must be a hash"]"</p>
  
  <p>How to make it work?</p>
  
  <p>app/controller/users_controller.rb</p>
  
  <pre><code>class UsersController &lt; ApplicationController
    def new
      @user = User.new
      @user.address = Address.new
      @user.company = Company.new
      @user.company.address = Address.new
    end
  
    def create
      @user = User.new
      validation = UserValidator::UserSchema.call(params)
      if validation.success?
        @user.attributes = validation.output[:user]
        @user.save
        redirect_to new_user_path, notice: 'Form send!'
      else
        redirect_to new_user_path, warning: "#{validation.errors}"
      end
   end
  end
  </code></pre>
  
  <p>app/models/user.rb</p>
  
  <pre><code>class User &lt; ApplicationRecord
    has_one :company
    has_one :address, as: :addressable
    accepts_nested_attributes_for :company, :address
  end
  </code></pre>
  
  <p>app/validators/user_validator</p>
  
  <pre><code>class UserValidator
    UserSchema = Dry::Validation.Params do
      required(:user).schema do
        required('first_name').filled
      end
    end
  end
  </code></pre>
  
  <p>print params output in create action:</p>
  
  <pre><code>&lt;ActionController::Parameters {"utf8"=&gt;"✓","authenticity_token"=&gt;"Dszr0k90aklK1NC4uGcemAl+yFa9ppMDo/gCLJt2wC1WjTgLC+NFebRqm6iqtVTnQzRgd7v0icntxETbxJ7v9g==", "user"=&gt;{"first_name"=&gt;"Test", "last_name"=&gt;"asdasdasdasd", "email_address"=&gt;"sadasdasd", "date_of_birth"=&gt;"sdasda", "phone_number"=&gt;"", "address_attributes"=&gt;{"street"=&gt;"dadadadsdad", "city"=&gt;"asdasdad", "zip_code"=&gt;"dasd", "country"=&gt;"adsa"}, "company_attributes"=&gt;{"name"=&gt;"", "address_attributes"=&gt;{"street"=&gt;"", "city"=&gt;"", "zip_code"=&gt;"", "country"=&gt;""}}}, "commit"=&gt;"Submit", "controller"=&gt;"users", "action"=&gt;"create"} permitted: false&gt;
  </code></pre>