Last change
on this file was 1ad8e64, checked in by Ema <ema_spirova@…>, 3 years ago |
spring security
|
-
Property mode
set to
100644
|
File size:
844 bytes
|
Line | |
---|
1 | package finki.diplomska.tripplanner.service.impl;
|
---|
2 |
|
---|
3 | import org.springframework.http.HttpStatus;
|
---|
4 | import org.springframework.http.ResponseEntity;
|
---|
5 | import org.springframework.stereotype.Service;
|
---|
6 | import org.springframework.validation.BindingResult;
|
---|
7 | import org.springframework.validation.FieldError;
|
---|
8 |
|
---|
9 | import java.util.HashMap;
|
---|
10 | import java.util.Map;
|
---|
11 |
|
---|
12 | @Service
|
---|
13 | public class MapValidationErrorService {
|
---|
14 | public ResponseEntity<?> MapValidationService(BindingResult result){
|
---|
15 |
|
---|
16 | if(result.hasErrors()){
|
---|
17 | Map<String, String> errorMap = new HashMap<>();
|
---|
18 |
|
---|
19 | for(FieldError error: result.getFieldErrors()){
|
---|
20 | errorMap.put(error.getField(), error.getDefaultMessage());
|
---|
21 | }
|
---|
22 | return new ResponseEntity<Map<String, String>>(errorMap, HttpStatus.BAD_REQUEST);
|
---|
23 | }
|
---|
24 |
|
---|
25 | return null;
|
---|
26 |
|
---|
27 | }
|
---|
28 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.