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

@Size annotation for strings inside Collection not working #372

Closed
zougamohamed opened this issue Oct 11, 2019 · 1 comment
Closed

@Size annotation for strings inside Collection not working #372

zougamohamed opened this issue Oct 11, 2019 · 1 comment

Comments

@zougamohamed
Copy link

Hello there,

I have a Set of Strings in my bean, and when generating a random instance, the generated strings don't respect the annotations.

private Set<@Size(min = 1, max = 10) String> listOfStrings;

Thanks

@fmbenhassine
Copy link
Member

What a good catch! Indeed, the @Size annotation is not honored in this case.

However, due to type erasure, I'm not sure it is possible to introspect the annotation on a generic type. I added a note about this limitation in the known limitations section of the wiki. You can use a custom randomizer for this kind of fields.

Thank you for reporting this anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants