Skip to content

Add (javax.)Validation Support for functional interface #2182

@GreenRover

Description

@GreenRover

For Stream binder there for support for the javax validation:
d93f170

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;
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions