Skip to content

feat: record based validation schemas#86

Draft
jbee wants to merge 19 commits intomainfrom
json-validation-classes
Draft

feat: record based validation schemas#86
jbee wants to merge 19 commits intomainfrom
json-validation-classes

Conversation

@jbee
Copy link
Collaborator

@jbee jbee commented Mar 4, 2026

API Changes

Changes from upgrading the access concept, mainly introduction of the to(Class) method and support for mapping to records and using records as validation schemas.

  • ✨ relaxed ? extends JsonObject restriction on all Class arguments for a validation schema
  • 🆎 replaced JsonTypedAccessStore with JsonAccessors
  • 🆎 replaced JsonValue#getAccessStore with JsonValue#getAccessors
  • 🆎 replaced JsonGenericTypedAccessor with JsonAccessor
  • 🆎 replaced JsonTypedAccessor with SimpleJsonAccessor
  • 🆔 renamed JsonTypedAccess to JsonAccess
  • ❌ removed JsonValue#isAccessCached
  • ❌ removed JsonValue#withAccessCached
  • 🆕 added JsonAccessException
  • ❌ removed METHOD as @Target for @Validation, @Validator and @ValidatorRepeat (covered by TYPE_USE)
  • 🆎 replaced METHOD as @Target for @Required with TYPE and TYPE_USE (covers METHOD)

Changes from upgrading to use Text views instead of String to represent path segments.

  • ✨ relaxed most methods in JsonObject and JsonNode API accepting a member name as String now accept a CharSequence
  • ✨ relaxed JsonNode#isElement to be defined on arrays and objects
  • JsonPath#toString now throws a JsonPathException when the path cannot be represented with syntax
  • ❌ removed JsonMixed, JsonValue and JsonNode of(Reader) method (using Text is a better way now)
  • ❌ removed JsonPath#keyOf (no longer needed)
  • ❌ removed JsonPath#shortenedBy (no longer needed)
  • ❌ removed JsonPath#dropFirstSegment (no longer needed)
  • ❌ removed JsonPath#objectMemberAtStart (no longer needed)
  • ❌ removed JsonPath#arrayIndexAtStart (no longer needed)
  • ❌ removed JsonPath#startsWithObject (no longer needed)
  • ❌ removed JsonPath#startsWithArray (no longer needed)
  • 🆔 renamed JsonPath#dropLastSegment to parentPath
  • 🆕 added JsonPath#extendedWith(Text)
  • ❌ removed JsonNode#memberOrNull(String)
  • ❌ removed JsonNode#member(String)
  • 🆕 JsonNode#get(Text)
  • 🆕 JsonNode#getOrNull(Text)
  • 🆕 JsonNode#member(Text)
  • 🆕 JsonNode#memberOrNull(Text)
  • 🆕 JsonNode#isMember
  • 🆕 JsonNode#element(Text)
  • 🆕 JsonNode#elementOrNull(Text)
  • 🆎 replaced String with Text in return type of JsonNode#getDeclaration
  • 🆎 replaced String with Text in return type of JsonNode#keys
  • 🆎 replaced String with Text in return type of JsonNode#members
  • 🆎 replaced String with Text in return type of JsonNode#members(boolean)
  • 🆎 replaced String with Text for JSON string and keys of JSON object entries in JsonNode#value
  • 🆎 JsonValue#path now returns JsonPath (was String)
  • 🆎 Validation.Error#path now is of type JsonPath (was String)
  • 🆎 JsonPathException#path now is of type JsonPath (was String)
  • 🆎 GetListener now accepts a JsonPath (was String)
  • ❌ removed JsonPrimitive#mapNonNull (not needed)

Bugfixes

  • 🐛 fixed JsonNode#get throws JsonTreeException (was JsonPathException) when the operation is used on a non-object node
  • 🐛 fixed JsonNode#getOrNull throws JsonTreeException (was JsonPathException) when the operation is used on a non-object node
  • 🐛 fixed JsonNumber#intValue throws JsonPathException (was NullPointerException) for a node defined JSON null (as stated in javadoc)
  • 🐛 fixed JsonAbstractObject#has throws JsonTreeException when called on an undefined parent

@jbee jbee self-assigned this Mar 4, 2026
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
59 New issues
58 New Code Smells (required ≤ 0)
1 New Bugs (required ≤ 0)
C Reliability Rating on New Code (required ≥ A)
3 New Critical Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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

Successfully merging this pull request may close these issues.

1 participant