Skip to content

Commit

Permalink
refactor: switch to NotBlank for record Dto validation
Browse files Browse the repository at this point in the history
  • Loading branch information
thisdudkin committed Sep 25, 2024
1 parent 0b891da commit 99b0fa6
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package dev.earlspilner.auth.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;

/**
* @author Alexander Dudkin
*/
@Schema(description = "Authentication request data")
public record AuthDto(
@NotNull
@NotBlank
@Schema(description = "User's username", example = "thisdudkin", requiredMode = Schema.RequiredMode.REQUIRED)
String username,

@NotNull
@NotBlank
@Schema(description = "User's password", example = "password", requiredMode = Schema.RequiredMode.REQUIRED)
String password
) { }
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package dev.earlspilner.auth.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;

/**
* @author Alexander Dudkin
*/
@Schema(description = "Access and refresh tokens")
public record Tokens(
@NotNull
@NotBlank
@Schema(description = "Access token", example = "eyJhbGciOiJIUzI1...", requiredMode = Schema.RequiredMode.REQUIRED)
String accessToken,

@NotNull
@NotBlank
@Schema(description = "Refresh token", example = "dXNlci1yZWZyZXNoLXRva2Vu..", requiredMode = Schema.RequiredMode.REQUIRED)
String refreshToken
) { }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;

import java.util.List;

Expand All @@ -14,10 +14,10 @@
@JsonInclude(NON_NULL)
public record UserDto(
Integer id,
@NotNull String name,
@NotNull String username,
@Email @NotNull String email,
@NotNull String password,
@NotBlank String name,
@NotBlank String username,
@Email @NotBlank String email,
@NotBlank String password,
String createdUtc,
String updatedUtc,
List<UserRole> roles
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.earlspilner.books.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;
import org.hibernate.validator.constraints.ISBN;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
Expand All @@ -12,11 +12,11 @@
@JsonInclude(NON_NULL)
public record BookDto(
Integer id,
@ISBN @NotNull String isbn,
@NotNull String title,
@NotNull String genre,
@NotNull String description,
@NotNull String author,
@ISBN @NotBlank String isbn,
@NotBlank String title,
@NotBlank String genre,
@NotBlank String description,
@NotBlank String author,
Boolean isAvailable,
String appearedUtc
) { }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;

import java.util.List;

Expand All @@ -14,10 +14,10 @@
@JsonInclude(NON_NULL)
public record UserDto(
Integer id,
@NotNull String name,
@NotNull String username,
@Email @NotNull String email,
@NotNull String password,
@NotBlank String name,
@NotBlank String username,
@Email @NotBlank String email,
@NotBlank String password,
String createdUtc,
String updatedUtc,
List<UserRole> roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;

import java.util.List;

Expand All @@ -14,10 +14,10 @@
@JsonInclude(NON_NULL)
public record UserDto(
Integer id,
@NotNull String name,
@NotNull String username,
@Email @NotNull String email,
@NotNull String password,
@NotBlank String name,
@NotBlank String username,
@Email @NotBlank String email,
@NotBlank String password,
String createdUtc,
String updatedUtc,
List<UserRole> roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;

import java.util.List;

Expand All @@ -14,10 +14,10 @@
@JsonInclude(NON_NULL)
public record UserDto(
Integer id,
@NotNull String name,
@NotNull String username,
@Email @NotNull String email,
@NotNull String password,
@NotBlank String name,
@NotBlank String username,
@Email @NotBlank String email,
@NotBlank String password,
String createdUtc,
String updatedUtc,
List<UserRole> roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import dev.earlspilner.users.model.UserRole;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;

import java.util.List;

Expand All @@ -15,10 +15,10 @@
@JsonInclude(NON_NULL)
public record UserDto(
Integer id,
@NotNull String name,
@NotNull String username,
@Email @NotNull String email,
@NotNull String password,
@NotBlank String name,
@NotBlank String username,
@Email @NotBlank String email,
@NotBlank String password,
String createdUtc,
String updatedUtc,
List<UserRole> roles
Expand Down

0 comments on commit 99b0fa6

Please sign in to comment.