Unify allowedKeys and allowedKeysWithConfig into single method#95
Open
cwperks wants to merge 1 commit into
Open
Unify allowedKeys and allowedKeysWithConfig into single method#95cwperks wants to merge 1 commit into
cwperks wants to merge 1 commit into
Conversation
f26c2c1 to
9dee5c0
Compare
Simplifies the REST API validation by removing the dual-method pattern (allowedKeys returning DataType map + allowedKeysWithConfig returning FieldConfiguration map). Now there is only allowedKeys() returning Map<String, FieldConfiguration>. - allowedKeys() return type changed from Map<String, DataType> to Map<String, FieldConfiguration> - allowedKeysWithConfig() removed from ValidationContext interface - All branching logic in RequestContentValidator removed - API actions use FieldConfiguration.of(DataType.X) for simple fields - Enhanced validation (maxLength, custom validators) uses the same method Signed-off-by: Craig Perkins <cwperks@amazon.com> Signed-off-by: Craig Perkins <cwperx@amazon.com>
9dee5c0 to
76e013a
Compare
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.
Summary
Simplifies the REST API validation by removing the dual-method pattern where
allowedKeys()returned aMap<String, DataType>andallowedKeysWithConfig()returned aMap<String, FieldConfiguration>. Now there is only one method:allowedKeys()returningMap<String, FieldConfiguration>.What changed
ValidationContext.allowedKeys()return type changed fromMap<String, DataType>toMap<String, FieldConfiguration>ValidationContext.allowedKeysWithConfig()removed entirelyRequestContentValidator(if (fieldConfigs != null) ... else ...) removedFieldConfiguration.of(DataType.X)for simple type-only validationallowedKeys()method withFieldConfiguration.of(DataType.X, maxLength, validator)Motivation
The two methods represented the same concept (defining valid request body fields) with confusing precedence rules.
allowedKeysWithConfig()silently overrodeallowedKeys()when present, and any API action implementing both had dead code in itsallowedKeys()method. This unification makes the validation path easier to trace and eliminates the cognitive overhead of choosing between two methods.Testing
All existing validation tests pass with no behavioral changes.