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

Required flag derived from NotEmpty annotation does not respect validation group of annotation #8

Open
beranradek opened this issue Jul 8, 2016 · 3 comments

Comments

@beranradek
Copy link
Owner

Required flag on some form field is still true even if field with NonEmpty annotation has unused validation group specified.

@lesinsa
Copy link

lesinsa commented Sep 2, 2019

Method net.formio.AbstractFormElement#isRequiredByAnnotations doesn't regards validation groups at all. Moreover, Size annotation is handled incorrect

						Size s = (Size) ann;
						if (s.min() > 0) {
							required = true;
							break;
						}

Minimal size should be effective when NotNull annotation is present only (recommended in JSR-303).

@lesinsa
Copy link

lesinsa commented Sep 3, 2019

Is project alive?

@beranradek
Copy link
Owner Author

@lesinsa you are right that Size annotation presence should not be checked within isRequiredByAnnotations. Null elements should be valid when the Size annotation is specified. I have released version 1.6.4 with that fix.

Recognizing validation groups within isRequiredByAnnotations is more conceptual problem - validation groups passed into bind method can be propagated (and stored) at AbstractFormElement level. You are welcome to create a pull request if you want to implement this feature yourself. For now, the library evaluates annotations in static way regarding the isRequired() getter.

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