21 lines
435 B
JavaScript
21 lines
435 B
JavaScript
|
|
export function fieldError(errors, field) {
|
||
|
|
return errors[field] || '';
|
||
|
|
}
|
||
|
|
|
||
|
|
export function normalizeValidationError(error) {
|
||
|
|
if (error?.details && typeof error.details === 'object') {
|
||
|
|
return error.details;
|
||
|
|
}
|
||
|
|
|
||
|
|
return {};
|
||
|
|
}
|
||
|
|
|
||
|
|
export function debounce(callback, wait = 300) {
|
||
|
|
let timeoutId;
|
||
|
|
|
||
|
|
return (...args) => {
|
||
|
|
window.clearTimeout(timeoutId);
|
||
|
|
timeoutId = window.setTimeout(() => callback(...args), wait);
|
||
|
|
};
|
||
|
|
}
|