Corrige validacao, recuperacao e acesso ao calculo do rascunho
This commit is contained in:
@@ -29,6 +29,22 @@ export function simulationApiErrorMessage(value: unknown): string | undefined {
|
||||
: value.message;
|
||||
}
|
||||
|
||||
/** Keep snapshot field errors attached to their original form fields. */
|
||||
export function simulationApiFieldErrors(
|
||||
value: unknown,
|
||||
): Record<string, string> {
|
||||
if (!isApiErrorV1(value)) return {};
|
||||
const fields: Record<string, string> = {};
|
||||
for (const [path, messages] of Object.entries(value.errors ?? {})) {
|
||||
const key = path
|
||||
.replace(/^(economic_snapshot|personal_snapshot)\./, '')
|
||||
.split('.')[0];
|
||||
if (/^[a-z][a-z0-9_]*$/.test(key) && messages.length)
|
||||
fields[key] = messages.join(' ');
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
/** Explain a failed status check without implying the accepted job was lost. */
|
||||
export function simulationPollingFailureMessage(value: unknown): string {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user