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

Subconfigurations validation seem to be not implemented #32

Open
Brikster opened this issue Aug 4, 2022 · 1 comment
Open

Subconfigurations validation seem to be not implemented #32

Brikster opened this issue Aug 4, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Brikster
Copy link

Brikster commented Aug 4, 2022

Describe the bug
I have such code:

@Getter
@SuppressWarnings("FieldMayBeFinal")
@Names(strategy = NameStrategy.HYPHEN_CASE, modifier = NameModifier.TO_LOWER_CASE)
public class ModerationConfig extends OkaeriConfig {

    private CapsModerationConfig caps = new CapsModerationConfig();

    @Positive
    private int exampleField = 6;

    @Getter
    @SuppressWarnings("FieldMayBeFinal")
    @Names(strategy = NameStrategy.HYPHEN_CASE, modifier = NameModifier.TO_LOWER_CASE)
    public static class CapsModerationConfig extends OkaeriConfig {

        private boolean enable = true;

        @Positive
        private int length = 6;

        @Min(0) @Max(100)
        private int percent = 80;

        private boolean block = true;

    }

}

If I set "exampleField" and "length" to zeros, I get exception only for the field from topper class. If I set to zero "length" only, result is the same.

Library version

implementation 'eu.okaeri:okaeri-configs-yaml-bukkit:4.0.6'
implementation 'eu.okaeri:okaeri-configs-serdes-commons:4.0.6'
implementation 'eu.okaeri:okaeri-configs-serdes-bukkit:4.0.6'
implementation 'eu.okaeri:okaeri-configs-validator-okaeri:4.0.6'
@dasavick dasavick added the bug Something isn't working label Aug 4, 2022
@dasavick
Copy link
Member

dasavick commented Jan 7, 2023

After giving it some thought (about half a year it seems), I believe this is actually a okaeri-validator limitation (related to OkaeriPoland/okaeri-validator#2) and not something to be fixed in the okaeri-configs directly.

I guess in the meanwhile, validator-jakartaee is a viable alternative. It may require @Valid annotation on the parent field, but that should be all that's needed to get multi level validation working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants