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

Validators (like NotNull etc) to be enabled during direct invoke. #61

Open
kingkong-AI opened this issue Jun 11, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@kingkong-AI
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Validators (like NotNull etc) don't work through direct invoke.
When using direct invoke on a controller for the DTO consisting of Validations, the validations are not processed and even if they don't satisfy, calls are successful, which is not ideal.

Example:

DTO:

public class UserDto {

    private String id;

    @NotEmpty
    @Size(min=1, message = "User name must be greater than 1 characters")
    private String name;

    @Email(message = "Invalid Email")
    private String email;

    @NotBlank
    @Pattern(regexp = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=!])(?=\\S+$).{5,20}$",
            message = "Password must be 5 to 20 characters long, "
                    + "contain at least one digit, one lowercase letter, "
                    + "one uppercase letter, and one special character "
                    + "from @#$%^&+=!")
    private String password;

    @NotNull
    @Positive(message = "Value must be positive")
    @Max(120)
    private int age;

Controller:

    @PostMapping
    public Mono<UserDto> createUser(@Valid @RequestBody UserDto userDto) {
        return userService.createUser(userDto);
    }

Describe the solution you'd like

A solution where:
All the validator annotations are processed properly even with direct invoke is expected, so that correct entries are populated in the database even with direct invoke.

Describe alternatives you've considered

No response

Additional context

No response

@kingkong-AI kingkong-AI added the enhancement New feature or request label Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant