Skip to content

Nested container element constraint (List<List<@NotBlank String>>) silently generates no adapter #384

Description

@ah3nan

A container element constraint inside another container is not supported, and the failure surfaces
late: the processor only warns, no adapter is generated, and validation then throws at runtime.

Reproduction

@Valid
record Direct(List<List<@NotBlank String>> matrix) {}

Validator.instance().validate(new Direct(List.of(List.of("x", ""))));

Compile output

warning: No Constraints Defined
    record Direct(List<List<@NotBlank String>> matrix) {}

No DirectValidationAdapter is generated.

Runtime

java.lang.IllegalArgumentException: No ValidationAdapter for class nest.Nest2$Direct
    at io.avaje.validation.core.CoreAdapterBuilder.buildForType(CoreAdapterBuilder.java:83)
    at io.avaje.validation.core.CoreAdapterBuilder.build(CoreAdapterBuilder.java:60)
    at io.avaje.validation.core.DValidator.adapter(DValidator.java:151)

Expected

Either support the nested container element constraint, or fail the build with an error (not a
warning) so the missing adapter cannot reach production.

Comparison

  • Hibernate Validator 9.1.2 validates List<List<@NotBlank String>> and reports
    grid[0].<list element>[1].<list element>.
  • avaje List<@NotBlank String> works (element violations reported, albeit with the malformed path
    of Issue 3), and List<@Valid Inner> works and reports items[0].name.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions