Git Product home page Git Product logo

Comments (11)

clemstoquart avatar clemstoquart commented on September 15, 2024 2

Hi @alimate

I'll try to provide a PR next week.

from errors-spring-boot-starter.

ErfanY avatar ErfanY commented on September 15, 2024 2

@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.

ErfanY avatar ErfanY commented on September 15, 2024 2

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.

alimate avatar alimate commented on September 15, 2024 1

@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.

alimate avatar alimate commented on September 15, 2024 1

@ErfanY @clemstoquart Thank you guys for reporting this issue πŸ™

from errors-spring-boot-starter.

alimate avatar alimate commented on September 15, 2024

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.

alimate avatar alimate commented on September 15, 2024

@clemstoquart That'd very much appreciated πŸ™

from errors-spring-boot-starter.

alimate avatar alimate commented on September 15, 2024

@ErfanY Glad you liked it β˜ΊοΈπŸ˜‰

from errors-spring-boot-starter.

clemstoquart avatar clemstoquart commented on September 15, 2024

@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.

ErfanY avatar ErfanY commented on September 15, 2024

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.

alimate avatar alimate commented on September 15, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.