feat(frontend): start settings
This commit is contained in:
parent
0c78cd25b0
commit
c179669799
13 changed files with 301 additions and 17 deletions
|
@ -52,3 +52,15 @@ export type ValidationError = {
|
|||
allowed_values?: any[];
|
||||
actual_value?: any;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the first error for the value `key` in `error`.
|
||||
* @param error The error object to traverse.
|
||||
* @param key The JSON key to find.
|
||||
*/
|
||||
export const firstErrorFor = (error: RawApiError, key: string): ValidationError | undefined => {
|
||||
if (!error.errors) return undefined;
|
||||
const field = error.errors.find((e) => e.key == key);
|
||||
if (!field?.errors) return undefined;
|
||||
return field.errors.length != 0 ? field.errors[0] : undefined;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue