zod-error
Version:
Utilities to format and customize Zod error messages
28 lines (27 loc) • 627 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLabel = void 0;
/**
* Gets a component label with fallback support.
* @export
* @template T
* @param {T} component
* @param {string} fallback
* @return {*} {string}
*/
function getLabel(component, fallback) {
if (component === undefined) {
return fallback;
}
if (component.enabled === false) {
return '';
}
if (component.label === undefined) {
return fallback;
}
if (component.label === null) {
return '';
}
return component.label;
}
exports.getLabel = getLabel;