Skip to content

Add same_as validator#1850

Merged
dblock merged 1 commit into
ruby-grape:masterfrom
glaucocustodio:same-as-validator
Dec 17, 2018
Merged

Add same_as validator#1850
dblock merged 1 commit into
ruby-grape:masterfrom
glaucocustodio:same-as-validator

Conversation

@glaucocustodio

Copy link
Copy Markdown
Contributor

Implements #1846.

Comment thread spec/spec_helper.rb
config.include Rack::Test::Methods
config.include Spec::Support::Helpers
config.raise_errors_for_deprecations!
config.filter_run_when_matching :focus

@glaucocustodio glaucocustodio Dec 17, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is out of scope of this PR, but I find it to be very useful. Can we keep?

@dblock dblock merged commit d2edd88 into ruby-grape:master Dec 17, 2018
@dblock

dblock commented Dec 17, 2018

Copy link
Copy Markdown
Member

Great stuff, merged. You can take this from here and make greater_than, less_than, etc.?

@glaucocustodio glaucocustodio deleted the same-as-validator branch December 17, 2018 20:25
@glaucocustodio

Copy link
Copy Markdown
Contributor Author

What about length: { min: 2, max: 20 } and length: { in: 2..20 }?

@dblock

dblock commented Dec 17, 2018

Copy link
Copy Markdown
Member

No, because I mean it should be relative to another value, eg.

params do
   requires :first
   requires :last, greater_than: :first
end

@dblock

dblock commented Dec 17, 2018

Copy link
Copy Markdown
Member

Related, it might make sense to extract (allow extraction of) some of these validators into separate gems at some point. We could have a whole bunch of mathematical validators, password strength validators, etc.

@glaucocustodio

Copy link
Copy Markdown
Contributor Author

Ok, I thought you were talking about length.. Gt/Lt make sense in this case.

I agree with the idea of extracting validators in another gem in the future..

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

Successfully merging this pull request may close these issues.

2 participants