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

option to skip validation on nested struct if value is nil #1

Closed
twistedlog opened this issue Sep 28, 2017 · 5 comments
Closed

option to skip validation on nested struct if value is nil #1

twistedlog opened this issue Sep 28, 2017 · 5 comments

Comments

@twistedlog
Copy link

There should be an option to skip validation of a nested struct if the nested struct's value is nil.

@RussellLuo
Copy link
Owner

This library tries to be small and composite, so any specific option will break this rule.

In the use case you mentioned, you can achieve it by combining Assert and Lazy. See Nested struct pointer for an example.

@RussellLuo
Copy link
Owner

As a supplement, it seems impossible to check whether a nested struct is nil or not, without using reflection?

@twistedlog
Copy link
Author

That's correct without refection its not possible, yes i think using Assert and Lazy in Any clause works.
Thanks.

@RussellLuo
Copy link
Owner

Yeah, Any(Assert(...), Lazy(...)) works :)

@RussellLuo
Copy link
Owner

@twistedlog I am going to close this issue, you can create a new one if you encountered other problems :)

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

2 participants