This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: custom validation response
- Loading branch information
1 parent
f338960
commit 38396be
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/main/java/br/com/fiap/grupo30/fastfood/adapters/in/rest/exceptions/FieldMessage.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package br.com.fiap.grupo30.fastfood.adapters.in.rest.exceptions; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class FieldMessage { | ||
private String fieldName; | ||
private String message; | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/br/com/fiap/grupo30/fastfood/adapters/in/rest/exceptions/ValidationError.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package br.com.fiap.grupo30.fastfood.adapters.in.rest.exceptions; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ValidationError extends StandardError { | ||
private final List<FieldMessage> errors = new ArrayList<>(); | ||
|
||
public void addError(String fieldName, String message) { | ||
errors.add(new FieldMessage(fieldName, message)); | ||
} | ||
} |