Добавление валидации #6
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Shop/UserService#6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Нужно ревьювить.
Описание мр'а добавь с тайтлом
@ -40,0 +47,4 @@@ExceptionHandler(MethodArgumentNotValidException.class)public ResponseEntity<Map<String, String>> handleValidationExceptions(MethodArgumentNotValidException ex) {Map<String, String> errors = new HashMap<>();давай сразу введем практику использования var в типе переменных
https://www.baeldung.com/java-10-local-variable-type-inference
Принял
@ -40,0 +53,4 @@String errorMessage = error.getDefaultMessage();errors.put(fieldName, errorMessage);});return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST);Давай также будем возвращать ошибки в каком то едином формате
Сделай отдельную дтошку для репрезентации ошибок
@ -0,0 +1,4 @@package ru.team58.profileservice.controller.exceptions;public class IncorrectEmailException extends BadRequestException {}Где используется?
@ -0,0 +24,4 @@@NotBlank(message = "First name cannot be empty")@Pattern(regexp = "^[a-zA-Zа-яА-Я]*$", message = "First name can contain only letters")@Size(min = 3, max = 255, message = "First name must be bigger than 3 and less than 255")А яну че делать
Ну, а янам вход воспрещен🫡
@ -0,0 +10,4 @@UserResponseMapper INSTANCE = Mappers.getMapper(UserResponseMapper.class);UserResponse toUserResponse(UserDTO dto);}Нравится, что разбил по разным мапперам
Не нравится, что обращаемся по статике к мапперам
А как обращаться?
@ -1,6 +1,7 @@package ru.team58.profileservice.persistence.entity;import jakarta.persistence.*;import jakarta.validation.constraints.*;Убираем
Фиксим и даю аппрув
devto Добавление валидацииView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.