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

Allow definition of custom types #993

Closed
lpil opened this issue Apr 17, 2015 · 2 comments
Closed

Allow definition of custom types #993

lpil opened this issue Apr 17, 2015 · 2 comments

Comments

@lpil
Copy link

lpil commented Apr 17, 2015

Hello! Thank you for Grape. :)

We would like to be able to do something like this:

params do
  requires :id, type: UUID, desc: 'Content id.'
end

Rather then set the type as String, and then validate the format of that string. We realise we can achieve the same result using validators, but we think this would be a more elegant, declarative syntax.

Is this possible?

Thanks,
Louis

@dblock
Copy link
Member

dblock commented Apr 17, 2015

It probably is with a bit of work - you need to dig through the implementation because type is something special. Grape's validation is based on Virtus (https://github.com/solnic/virtus), so I think defining a Virtus type for UUID would be sufficient. I don't know exactly how, will leave this open as a feature request.

@dblock
Copy link
Member

dblock commented Jun 24, 2015

Closed via #1039.

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

No branches or pull requests

2 participants