schyma
Version:
JSON Schemas Visualizer React component
14 lines • 549 B
JavaScript
export function formatRequiredSentence(fields) {
if (!fields || fields.length === 0)
return '';
if (fields.length === 1) {
return `The ${fields[0]} is required for this property`;
}
if (fields.length === 2) {
return `The ${fields[0]} and ${fields[1]} are required for this property`;
}
const allButLast = fields.slice(0, -1).join(', ');
const last = fields[fields.length - 1];
return `The ${allButLast}, and ${last} are required for this property`;
}
//# sourceMappingURL=formatRequired.js.map