HV-2193: Create a new constraint @NullOrNotBlank similar to @NotBlank for use with nullable fields and Optional<> - #1906
Open
koentsje wants to merge 7 commits into
Open
HV-2193: Create a new constraint @NullOrNotBlank similar to @NotBlank for use with nullable fields and Optional<>#1906koentsje wants to merge 7 commits into
koentsje wants to merge 7 commits into
Conversation
…for use with nullable fields and Optional - Add the initial implementation of constraint NullOrNotBlank Signed-off-by: Koen Aers <koen.aers@gmail.com>
- Add NullOrNotBlankValidator for CharSequence validation - Add NullOrNotBlankValidatorTest covering null, not blank, empty and blank cases Signed-off-by: Koen Aers <koen.aers@gmail.com>
- Register NullOrNotBlank in BuiltinConstraint and ConstraintHelper - Add validation message to ValidationMessages.properties - Update MessagePropertiesTest and PredefinedScopeAllConstraintsTest - Add NullOrNotBlankConstrainedTest covering direct field and Optional usage Signed-off-by: Koen Aers <koen.aers@gmail.com>
- Add NullOrNotBlankDef class Signed-off-by: Koen Aers <koen.aers@gmail.com>
- Add @testForissue(jiraKey = "HV-2193") to NullOrNotBlankValidatorTest and NullOrNotBlankConstrainedTest - Add testProgrammaticDefinition test for NullOrNotBlankDef in NullOrNotBlankValidatorTest Signed-off-by: Koen Aers <koen.aers@gmail.com>
- Add NULL_OR_NOT_BLANK constant to TypeNames - Register NullOrNotBlank for CharSequence in AP ConstraintHelper - Add ModelWithNullOrNotBlankConstraints test model - Add nullOrNotBlankConstraints test to ConstraintValidationProcessorIT Signed-off-by: Koen Aers <koen.aers@gmail.com>
- Add @NullOrNotBlank entry to the reference guide in chapter 2 Signed-off-by: Koen Aers <koen.aers@gmail.com>
marko-bekhta
left a comment
Member
There was a problem hiding this comment.
Hey @koentsje 👋🏻 🙂
thanks! looks good, let's update that since tag and merge ?
| /** | ||
| * Constraint definition for {@link NullOrNotBlank}. | ||
| * @author Koen Aers | ||
| * @since 9.1 |
Member
There was a problem hiding this comment.
Suggested change
| * @since 9.1 | |
| * @since 9.2 |
as 9.1 is already out, we'll add it to the 9.2 🙂
| * (extracted as {@code null}) should be valid, but a present value must not be blank. | ||
| * | ||
| * @author Koen Aers | ||
| * @since 9.1 |
Member
There was a problem hiding this comment.
Suggested change
| * @since 9.1 | |
| * @since 9.2 |
and here 🙂
Contributor
|
Hi! Thanks for this useful addition. I raised this topic back in November on the mailing list and opened an issue in the Jakarta Validation project. Just wanted to check: are there any plans to introduce |
Contributor
|
@marko-bekhta ping. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Add a new Hibernate Validator specific constraint @NullOrNotBlank that validates a character sequence is either null or contains at least one non-whitespace character.
See: https://hibernate.atlassian.net/browse/HV-2193
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on licensing, please check here.