src/main/java/br/eng/joaofaro/taskmanager/exception/TaskManagerExceptionHandler.java
/**
     * <p>Validation handle when create a new task</p>
     *
     * @return list of errors model
     */
Validation handle when create a new task
@return list of errors model
Validation handle when create a new task @return list of errors model
@ResponseStatus(code = HttpStatus.BAD_REQUEST)
    @ExceptionHandler(MethodArgumentNotValidException.class)
    public List<TaskManagerFormErrorDto> DtoValidationHandle(MethodArgumentNotValidException exception) {
        ArrayList<TaskManagerFormErrorDto> erros = new ArrayList<>();
        List<FieldError> fieldErrors = exception.getBindingResult().getFieldErrors();
        fieldErrors.forEach(e -> {
            String message = messageSource.getMessage(e, LocaleContextHolder.getLocale());
            TaskManagerFormErrorDto errorDto = new TaskManagerFormErrorDto(HttpStatus.BAD_REQUEST.value(),
                    e.getField(), message);
            erros.add(errorDto);
        });
        return erros;
    }
@ ResponseStatus ( code = HttpStatus . BAD_REQUEST ) @ ExceptionHandler ( MethodArgumentNotValidException . class ) public List < TaskManagerFormErrorDto > DtoValidationHandle ( MethodArgumentNotValidException exception ) { ArrayList < TaskManagerFormErrorDto > erros = new ArrayList < > ( ) ; List < FieldError > fieldErrors = exception . getBindingResult ( ) . getFieldErrors ( ) ; fieldErrors . forEach ( e -> { String message = messageSource . getMessage ( e , LocaleContextHolder . getLocale ( ) ) ; TaskManagerFormErrorDto errorDto = new TaskManagerFormErrorDto ( HttpStatus . BAD_REQUEST . value ( ) , e . getField ( ) , message ) ; erros . add ( errorDto ) ; } ) ; return erros ; }
<p>Validation handle when create a new task</p>
 @return list of errors model
<p > Validation handle when create a new task< / p > @return list of errors model