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

allMandatoryParameters and validationMethod = NONE don't work together #1271

Closed
xtaixe opened this issue Mar 15, 2021 · 3 comments
Closed

allMandatoryParameters and validationMethod = NONE don't work together #1271

xtaixe opened this issue Mar 15, 2021 · 3 comments

Comments

@xtaixe
Copy link

xtaixe commented Mar 15, 2021

Hi. It seems that there is an incompatibility between allMandatoryParameters and validationMethod = NONE.

When having something like:

@Value.Immutable
@Value.Style(
        allMandatoryParameters = true,
        typeAbstract = "_*",
        typeImmutable = "*",
        validationMethod = NONE,
        defaults = @Value.Immutable(builder = false))
public interface _MyType {

    String property();

}

only a no-args factory method MyType.of() is created instead of the expected MyType.of(String property).

If I use allParameters instead of allMandatoryParameters or remove validationMethod = NONE everything works as expected.

@elucash
Copy link
Member

elucash commented Mar 16, 2021

yes, seems like something that can be fixed, thank you

@elucash
Copy link
Member

elucash commented Apr 18, 2021

I've reread ValidationMethod.NONE javadoc and it seems that it is making attributes non mandatory, and unfortunately enough users might rely on this behavior even if a little bit regrettable in a way it is named/documented. So "fixing" it is not an option.
I've introduced new ValidationMethod.MANDATORY_ONLY constant to still have non-nullable non-default attributes mandatory with the regular check for missing attributes, just omit null-check on value.

@elucash elucash added this to the 2.9.0 milestone Jan 19, 2022
@elucash
Copy link
Member

elucash commented Jan 19, 2022

released in 2.9.0

@elucash elucash closed this as completed Jan 19, 2022
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