-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from anishmu20/feature/api-validation
Feature/api validation
- Loading branch information
Showing
10 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/libraryman_api/member/dto/MembersDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,35 @@ | ||
package com.libraryman_api.member.dto; | ||
|
||
import com.libraryman_api.member.Role; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Pattern; | ||
import jakarta.validation.constraints.Size; | ||
|
||
import java.util.Date; | ||
|
||
public class MembersDto { | ||
|
||
private int memberId; | ||
@NotBlank(message = "Name is required") | ||
@Size(min = 2, max = 100, message = "Name must be between 2 and 100 characters") | ||
private String name; | ||
@NotBlank(message = "Username is required") | ||
@Size(min = 4, max = 50, message = "Username must be between 4 and 50 characters") | ||
private String username; | ||
|
||
@Pattern(regexp = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$", message = "Please enter a valid email address (e.g., [email protected])") | ||
@NotBlank(message = "Email field cannot be empty. Please provide a valid email address.") | ||
private String email; | ||
|
||
@NotBlank(message = "Password is required") | ||
@Size(min = 8, message = "Password must be at least 8 characters long") | ||
@Pattern(regexp = "^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[@#$%^&+=]).*$", | ||
message = "Password must contain at least one letter, one number, and one special character") | ||
private String password; | ||
|
||
|
||
private Role role; | ||
|
||
private Date membershipDate; | ||
|
||
public MembersDto(int memberId, String name, String username, String email, String password, Role role, Date membershipDate) { | ||
|
11 changes: 10 additions & 1 deletion
11
src/main/java/com/libraryman_api/member/dto/UpdateMembersDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
package com.libraryman_api.member.dto; | ||
|
||
public class UpdateMembersDto { | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Pattern; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public class UpdateMembersDto { | ||
@NotBlank(message = "Name is required") | ||
@Size(min = 2, max = 100, message = "Name must be between 2 and 100 characters") | ||
private String name; | ||
@NotBlank(message = "Username is required") | ||
@Size(min = 4, max = 50, message = "Username must be between 4 and 50 characters") | ||
private String username; | ||
@Pattern(regexp = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$", message = "Please enter a valid email address (e.g., [email protected])") | ||
@NotBlank(message = "Email field cannot be empty. Please provide a valid email address.") | ||
private String email; | ||
|
||
public UpdateMembersDto(String name, String username, String email) { | ||
|
10 changes: 9 additions & 1 deletion
10
src/main/java/com/libraryman_api/member/dto/UpdatePasswordDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters