-
Notifications
You must be signed in to change notification settings - Fork 573
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
Explore FreeForm validation v2 #989
Open
marko-bekhta
wants to merge
14
commits into
hibernate:main
Choose a base branch
from
marko-bekhta:json
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f61a93d
[property-holder-preparation] Remove impossible case from ValidatorIm…
marko-bekhta 80a4bb8
[property-holder-preparation] Delegate retrieving bean metadata to Ca…
marko-bekhta 9418a35
[property-holder] Introduce property holder property and property holder
marko-bekhta 415abf7
[property-holder-preparation] Move metadata manager to its own package
marko-bekhta 4a523a8
[property-holder-preparation] Extract bean metadata provider code to its
marko-bekhta 37d4545
[property-holder-preparation] Extract BeanMetaDataBuilder to upper level
marko-bekhta 00a7af7
[property-holder-preparation] Make ConstraintMetaDataManager return m…
marko-bekhta f75e407
[property-holder] Create implementations of cascading metadata for pr…
marko-bekhta ac7835f
[property-holder] Make property holder configuration use location bui…
marko-bekhta 92b0696
[property-holder] Introduce dummy metadata provider for property holders
marko-bekhta 4e021be
[property-holder] Introduce method for validating property holders an…
marko-bekhta 9f1b1da
[property-holder] Rework how constraints are validated for default group
marko-bekhta 1807098
[property-holder] Rewrite how cascading constraints are created
marko-bekhta 8076e67
[property-holder] start working on programmatic definition
marko-bekhta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -597,7 +597,7 @@ private void validateCascadedAnnotatedObjectForCurrentGroup(Object value, BaseBe | |
// already and need only to pass the current element | ||
ValidationOrder validationOrder = validationOrderGenerator.getValidationOrder( currentGroup, currentGroup != originalGroup ); | ||
|
||
ValueContext<?, Object> cascadedValueContext = buildNewLocalExecutionContext( valueContext, value ); | ||
ValueContext<?, Object> cascadedValueContext = buildNewLocalExecutionContext( cascadingMetaData, valueContext, value ); | ||
|
||
validateInContext( validationContext, cascadedValueContext, validationOrder ); | ||
} | ||
|
@@ -675,7 +675,7 @@ private void doValidate(Object value, String nodeName) { | |
// already and need only to pass the current element | ||
ValidationOrder validationOrder = validationOrderGenerator.getValidationOrder( currentGroup, currentGroup != originalGroup ); | ||
|
||
ValueContext<?, Object> cascadedValueContext = buildNewLocalExecutionContext( valueContext, value ); | ||
ValueContext<?, Object> cascadedValueContext = buildNewLocalExecutionContext( cascadingMetaData, valueContext, value ); | ||
|
||
if ( cascadingMetaData.getDeclaredContainerClass() != null ) { | ||
cascadedValueContext.setTypeParameter( cascadingMetaData.getDeclaredContainerClass(), cascadingMetaData.getDeclaredTypeParameterIndex() ); | ||
|
@@ -688,7 +688,7 @@ private void doValidate(Object value, String nodeName) { | |
|
||
// Cascade validation to container elements if we are dealing with a container element | ||
if ( cascadingMetaData.hasContainerElementsMarkedForCascading() ) { | ||
ValueContext<?, Object> cascadedTypeArgumentValueContext = buildNewLocalExecutionContext( valueContext, value ); | ||
ValueContext<?, Object> cascadedTypeArgumentValueContext = buildNewLocalExecutionContext( cascadingMetaData, valueContext, value ); | ||
if ( cascadingMetaData.getTypeParameter() != null ) { | ||
cascadedValueContext.setTypeParameter( cascadingMetaData.getDeclaredContainerClass(), cascadingMetaData.getDeclaredTypeParameterIndex() ); | ||
} | ||
|
@@ -737,25 +737,16 @@ private void validateCascadedContainerElementsInContext(Object value, BaseBeanVa | |
} | ||
} | ||
|
||
private ValueContext<?, Object> buildNewLocalExecutionContext(ValueContext<?, ?> valueContext, Object value) { | ||
private ValueContext<?, Object> buildNewLocalExecutionContext(CascadingMetaData cascadingMetaData, ValueContext<?, ?> valueContext, Object value) { | ||
ValueContext<?, Object> newValueContext; | ||
if ( value != null ) { | ||
newValueContext = ValueContext.getLocalExecutionContext( | ||
validatorScopedContext.getParameterNameProvider(), | ||
value, | ||
beanMetaDataManager.getBeanMetaData( value.getClass() ), | ||
valueContext.getPropertyPath() | ||
); | ||
newValueContext.setCurrentValidatedValue( value ); | ||
} | ||
else { | ||
newValueContext = ValueContext.getLocalExecutionContext( | ||
validatorScopedContext.getParameterNameProvider(), | ||
valueContext.getCurrentBeanType(), | ||
valueContext.getCurrentBeanMetaData(), | ||
valueContext.getPropertyPath() | ||
); | ||
} | ||
Contracts.assertNotNull( value, "value cannot be null" ); | ||
newValueContext = ValueContext.getLocalExecutionContext( | ||
validatorScopedContext.getParameterNameProvider(), | ||
value, | ||
cascadingMetaData.getBeanMetaDataForCascadable( beanMetaDataManager, value ), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you expect to have the metadata for the free form case in the If not, I suspect we should push the Not sure what you had in mind for that? |
||
valueContext.getPropertyPath() | ||
); | ||
newValueContext.setCurrentValidatedValue( value ); | ||
|
||
return newValueContext; | ||
} | ||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on the usage of this method null values could not be passed in here, as they go through a different logical branch. Reducing the number of different variations of
ValueContext
creations helps to fit in the property holders in the future.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I merged this one.