Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameters validation #109

Closed
nicolas-besnard opened this issue May 18, 2016 · 5 comments
Closed

Parameters validation #109

nicolas-besnard opened this issue May 18, 2016 · 5 comments

Comments

@nicolas-besnard
Copy link

nicolas-besnard commented May 18, 2016

Do you think it can be possible to add parameters validation to this library ?

context_param :user, presence: true, is_a: 'User

or even a simpler v1:

context_params :user, -> (context) {}

or using some library like rails_param ?

I'll be happy to make a PR for this :)

@ryansch
Copy link

ryansch commented Jun 5, 2016

I just open sourced metaractor which does required/optional parameters and some error control (valid/not valid). It does not do coercion or type checking.

@philipgiuliani
Copy link

philipgiuliani commented Jun 24, 2016

Im using https://github.com/jonstokes/troupe in all of my projects for a long time!
There is also this PR open #82

@adis-io
Copy link

adis-io commented Aug 8, 2016

class RegisterClient
  include Interactor
  include RailsParam::Param

  before :validate_params

  def call
    binding.pry
  end

  def params
    context.params
  end

  def validate_params
    begin
      param! :attribution, String, required: true
    rescue => e
      context.fail!(message: e.message)
    end
  end
end

This is what I did. It works fine. BTW I used this gem: https://github.com/nicolasblanco/rails_param

@berfarah
Copy link

berfarah commented Feb 7, 2017

To add to this, I've implemented schema validation for the Interactor::Context - you can see my gem here https://github.com/berfarah/interactor-schema

@laserlemon
Copy link
Collaborator

Closing in favor of #123.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants