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

Add methods in KiwiConstraintViolations to convert constraint violations to maps #1169

Closed
sleberknight opened this issue Jul 26, 2024 · 0 comments · Fixed by #1171
Closed
Assignees
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

sleberknight commented Jul 26, 2024

Add methods in KiwiConstraintViolations to convert Set<ConstraintViolation<T> to JDK Map and Guava Multimap.

Specifically, methods to convert a set of constraint violations to:

  • a Map<String, ConstraintViolation<T>> assuming there can only be a single violation per property. Throw an IllegalStateException if more than one violation for a property.
  • a Map<String, ConstraintViolation<T>>, ignoring more than one violation per property and taking the last violation when there is more than one for a property.
  • a Map<String, Set<ConstraintViolation<T>>> allowing for one or more violation per property.
  • a (Guava) Multimap<String, ConstraintViolation<T>> allowing for one or more violation per property.

There can be overloads of each of the above that accept a Function<Path, String> that specifies how to transform a property Path to a String. The default implementations can simply use Path::toString.

@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Jul 26, 2024
@sleberknight sleberknight added this to the 4.2.0 milestone Jul 26, 2024
sleberknight added a commit that referenced this issue Jul 27, 2024
* Add asMap, asSingleValuedMap, asMultiValuedMap, and asMultimap
  methods to convert a Set of ConstraintViolation into a JDK or
  Guava Multimap. Overloads provide the ability to customize the
  translation from a property Path to the map key.
* Add pathStringOf, a pure convenience method to eliminate boilerplate.
* Clean up a few minor grammatical errors in javadoc.

Closes #1169
Closes #1170
sleberknight added a commit that referenced this issue Jul 29, 2024
* Add asMap, asSingleValuedMap, asMultiValuedMap, and asMultimap methods
to convert a Set of ConstraintViolation into a JDK or Guava Multimap.
Overloads provide the ability to customize the translation from a
property Path to the map key.
* Add pathStringOf, a pure convenience method to eliminate boilerplate.
* Clean up a few minor grammatical errors in javadoc.

Closes #1169
Closes #1170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant