spring-cloud / spring-cloud/spring-cloud-stream

Add (javax.)Validation Support for functional interface

Open
#2,182 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

ideal-for-contribution
Dominant language
Java
Stars
1.1k
Forks
646
Avg merge
2d 3h
Merged PRs (30d)
8

Description

For Stream binder there for support for the javax validation:
https://github.com/spring-cloud/spring-cloud-stream/commit/d93f170f2e82319300b825c0437523353fc3c590

But it seams for the functional interface it is gone.
It would expect this throwing a error when a message with invalid person name was received instead calling the log() method.

@SpringBootApplication
public class LoggingConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(LoggingConsumerApplication.class, args);
    }

    @Bean
    public Consumer<Message<@Valid Person>> log() {
        return msg -> {
            System.out.println("Received: " + msg.getPayload());
        };
    }

    public static class Person {
        private String name;
        public String getName() {
            return name;
        }
        @Pattern(regexp = "^[a-zA-Z_:][a-zA-Z0-9_:]*$")
        public void setName(String name) {
            this.name = name;
        }
        public String toString() {
            return this.name;
        }
    }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the existing javax validation support in the linked Stream binder commit with functional-interface message handling, especially the Consumer<Message<@Valid Person>> example. Add a regression test showing that an invalid Person prevents log() from being invoked and produces a validation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.