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
Provide a means for supplying a validator #41
Comments
I think smart constructors can do what you want (using visibility = Smart). eg. https://github.com/jbgi/Softshake2015Demo/blob/70c23ac39640ef678361c9066d37373dfff1f712/src/main/java/com/github/jbgi/softshake/domain/model/PersonName.java#L85 Would that style suit your needs? |
Hard to tell, since whenever I add an Without seeing that that generates hard to say, the problem I have with smart constructors on the abstract class, is then you've got two locations for dealing with things - the pluralized class with get/mod methods etc, and the abstract with constructors. |
@talios about the error: could it be because you depends on an older version of the as for validation. I see that generating the validation code would be nice indeed. However, unlike with null, I want them to be safe: generated smart constructors would return something like The validation code would be taken from an static instance of the visitor of the ADT that return either a |
This is the project: https://github.com/HalBuilder/halbuilder-core and https://github.com/HalBuilder/halbuilder-core/blob/develop/src/main/java/com/theoryinpractise/halbuilder5/Rel.java is the derive4j class. |
@talios using the following one @Data(value = @Derive(withVisibility = Visibility.Smart),
flavour = Flavour.Javaslang, arguments = ArgOption.checkedNotNull) What |
closing in favor of #44 |
I was thinking it would be handy to have some means of providing a validator over the ADT values, I often use this feature of Immutables and keep thinking it would be useful here.
Currently, derive4j checks for nullness in its created instances, but it would be nice if we could define something like:
or
which if existed, gets called before returning the constructed value.
Thoughts?
The text was updated successfully, but these errors were encountered: