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

Required attribute #355

Closed
vladra opened this issue Mar 26, 2016 · 1 comment
Closed

Required attribute #355

vladra opened this issue Mar 26, 2016 · 1 comment

Comments

@vladra
Copy link

vladra commented Mar 26, 2016

Hi guys

I was wondering if there is an ability to mark attribute as required. So if attribute is not passed in this case, it should raise some error. I found required option for attribute, but not sure how to use it.

So, is it possible to require mandatory attribute?

Thanks for help!

@vladra
Copy link
Author

vladra commented Mar 26, 2016

I will specify question a bit. It's actually working with build in types, just haven't tried that (with String for example). But is doesn't work with my models (for example User).

With build in type:
attribute :city, String
=> Virtus::CoercionError: Failed to coerce attribute city from nil into String

With my mode:
attribute :user, User
=> no failure error

@vladra vladra closed this as completed Jul 22, 2016
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

1 participant