@vtaits/react-hook-form-schema
Version:
Integration of react-hook-form and @vtaits/form-schema
32 lines (31 loc) • 741 B
JavaScript
// src/fields/base/renderError.tsx
import { jsx } from "react/jsx-runtime";
function renderArray(errors) {
return errors.map((errorItem, index) => (
// biome-ignore lint/suspicious/noArrayIndexKey: there is no id
/* @__PURE__ */ jsx("div", { children: renderError(errorItem) }, index)
));
}
function renderError(error) {
if (!error) {
return null;
}
if (typeof error === "string") {
return error;
}
if (Array.isArray(error)) {
return renderArray(error);
}
const message = error.message;
if (typeof message === "string") {
return message;
}
if (Array.isArray(message)) {
return renderArray(message);
}
return null;
}
export {
renderError
};
//# sourceMappingURL=chunk-XUSORK34.js.map