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

Easy way to ensure all fields are non-null #79

Open
Diagoras opened this issue Sep 8, 2016 · 2 comments
Open

Easy way to ensure all fields are non-null #79

Diagoras opened this issue Sep 8, 2016 · 2 comments

Comments

@Diagoras
Copy link
Contributor

Diagoras commented Sep 8, 2016

Idiomatic Scala doesn't use null, so it'd be nice for there to be an easy way to guarantee that all the fields of a validated record are non-null without boiler plate field1 is notNull, field2 is notNull, etc.

@holograph
Copy link
Contributor

While you can always implement a validator yourself, from a core library perspective this doesn't seem compelling (I can think of a couple of counter-arguments); implementing this with reflection goes against the grain of Accord, and a typesafe solution is too much work just for this feature.

Then again, perhaps an "iterator-style" modifier on fields? Then you can do something like p.fields.each is notNull, which might be an interesting exercise in using Shapeless (CCing @noam-almog :-)).

@Diagoras
Copy link
Contributor Author

Diagoras commented Nov 2, 2016

I agree with both avoiding reflection and that a type safe solution would be tricky, which doesn't leave a lot to work with I guess. The Shapeless solution looks good though, if it's not too much trouble.

@holograph holograph self-assigned this Nov 29, 2016
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