UNPKG

tamim-cli

Version:

A CLI tool for generating module boilerplate code including routes, controllers, services, and more

23 lines (22 loc) 807 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseFields = void 0; const parseFields = (fields) => { return fields.map((field) => { if (!field) { throw new Error("Field definition cannot be empty"); } const [fieldName, fieldType] = (field === null || field === void 0 ? void 0 : field.includes("?:")) ? field.replace("?:", ":").split(":") : field.split(":"); if (!fieldName || !fieldType) { throw new Error(`Invalid field format: ${field}. Expected format: name:type`); } return { name: fieldName.trim(), type: fieldType.trim(), isRequired: !field.toString().includes("?"), }; }); }; exports.parseFields = parseFields;