Comments (11)
Hi @alimate
I'll try to provide a PR next week.
from errors-spring-boot-starter.
@clemstoquart have you started on this PR? I'm actually having the same problem where I specially would like to have the invalid parameter names in the response and thought to do a PR.
If you have started and not yet completed maybe I can help around if you don't have enough time on your hand.
Thanks! And @alimate, great library, cheers mate! π
from errors-spring-boot-starter.
Thanks @alimate!
Silly me! Halfway through implementation of including arguments to have property
parameter in the error response I saw that there is already support for exposing arguments that can be achieved using the property errors.expose-arguments=ALWAYS
.
As for the the messages, I liked your idea of thinking where we actually get the property name right in the error message in the format of propertyPath.ConstraintName
, really nice idea!!!
I will check your code in detail, from the first sight, it looks much more than just "prototypical PoC" π.
Thanks! Appreciate the support and your time on this open source project.
from errors-spring-boot-starter.
@clemstoquart @ErfanY I have a prototypical PoC here that may come useful.
Suppose, you have a to-be-validated DTO as following:
class SomeDto {
@NotBlank
private String text;
@URL
private String callback;
@Min(message = "", value = 5)
private int num;
@NotBlank(message = " ")
private String another;
@Valid
private Default nested;
// getters and setters
}
Then if we pass a blank value to the text
field, then the error code would be text.NotBlank
instead of javax.validation.blah
.
Basically, the error code would follow the propertyPath.ConstraintName
format.
from errors-spring-boot-starter.
@ErfanY @clemstoquart Thank you guys for reporting this issue π
from errors-spring-boot-starter.
Hey @clemstoquart. Thanks for reporting this issue. I was able to reproduce the issue and yeah, you're right. Your suggestion seems valid to me π
from errors-spring-boot-starter.
@clemstoquart That'd very much appreciated π
from errors-spring-boot-starter.
@ErfanY Glad you liked it
from errors-spring-boot-starter.
@ErfanY I've somehow started working on the subject but it was more complicated than expected. I don't have any working implementation right now.
from errors-spring-boot-starter.
Make sense! All of those constraints are in either of javax.validation
or org.hibernate
.
The only complexity comes to constraints like Size
with min and max. Where the message would not really give a better information on the valid intervals.
This implementation fits perfect for those annotation constraints where the annotation itself is self explanatory and does not have any internal parameters that's needed to provide information?
from errors-spring-boot-starter.
@ErfanY We can abstract away the error code generation mechanism with something like:
interface ErrorCodeGenerator<T> {
String generate(T context);
}
Then we can provide simple Bean Validation implementations to handle different types of ConstraintViolation<T>
s. But probably this would be a bit overkill for now. What do you think?
With the current approach, it would hard to handle all possible cases of constraint violations
from errors-spring-boot-starter.
Related Issues (20)
- Not all errors added when using same code on multiple fields HOT 4
- How to make use of fingerprint id to correlate with log exception detail? HOT 2
- Question about ErrorController HOT 2
- Human readable error message gives null when using a custom exception. HOT 1
- default return content-type is `application/xhtml+xml`, how to change it to json?
- Support Runtime Message(s)
- ReactiveErrorAttributes uses inexistent DefaultErrorAttributes(boolean) constructor
- Is this project still alive ?
- Add support to pick fields of the Exception class HOT 3
- @SpringBootTest and @AutoConfigureMockMvc errors not mocked HOT 4
- Provide support for using Kotlin HOT 2
- Handle MaxUploadSizeExceededException Exception HOT 1
- Handle General MultipartExceptions HOT 1
- Using @SpringBootTests to Bootstrap Integration Tests
- Will get null message when locale is not default even if there is default messages.properties HOT 2
- No error handling HOT 2
- Migrate to Github Actions
- Support Java 12 and Java 13
- Example for 'Customizing the Error Representation' not working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from errors-spring-boot-starter.