-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b3f78f
commit b943424
Showing
4 changed files
with
32 additions
and
4 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
15 changes: 15 additions & 0 deletions
15
nivel-03/02-iniciando-o-front-end-web/src/utils/getValidationErrors.ts
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,15 @@ | ||
import { ValidationError } from 'yup'; | ||
|
||
interface Errors { | ||
[key: string]: string; | ||
} | ||
|
||
export default function getValidationErrors(err: ValidationError): Errors { | ||
const validationErrors: Errors = {}; | ||
|
||
err.inner.forEach(error => { | ||
validationErrors[error.path] = error.message; | ||
}); | ||
|
||
return validationErrors; | ||
} |
b943424
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recebi na linha 11 de [nivel-03/02-iniciando-o-front-end-web/src/utils/getValidationErrors.ts ] o erro de que 'undefined' não poderia ser usado como index type.
Corrigi usando:
err.inner.forEach(error => { if (error.path) validationErrors[error.path] = error.message; });
Espero que isso possa ajudar alguém.
b943424
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me ajudou. Muito obrigado!
b943424
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acabou me ajudando tbm, estava dando erro para mim
b943424
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wilsonfaustino obrigado por esse feedback! Irei adicionar isso na descrição da aula 💜
b943424
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ajudou muito @wilsonfaustino muito obrigado.