-
Notifications
You must be signed in to change notification settings - Fork 34
Feature Request: Support for list elements #31
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
Comments
For a list, it should be |
|
Technically speaking, javax supports both collections and strings. https://javaee.github.io/javaee-spec/javadocs/javax/validation/constraints/NotEmpty.html. NotEmpty will allow whitespace characters, while NotBlank will ensure you have at least one non whitespace char. But the way you can validate a list or the elements of a list with javax is as follow: // list not empty
public @NotEmpty List<String> field;
// strings in the list not empty
public List<@NotEmpty String> field; The equivalent syntax does not compile in GraphQL. // works
field: [String] @NotEmpty
// does not work
field: [String @NotEmpty ] Thus making it impossible to validate that strings are not empty and that lists are not empty at the same time. Same issue occurs with In the linked MR, I came up with |
It would be great to have support of validation for list items.
For instance with this query schema
The
@NotBlank
could validate that every element of the list is not blank. This applies indeed for all the validations, except maybe for theexpression
, which could still be useful to use on a full listThe text was updated successfully, but these errors were encountered: