UNPKG

@pompeii-labs/cli

Version:

Magma CLI

24 lines (23 loc) 763 B
const AgentFileValidationError = Error; function validateAgentFiles(files) { if (!files) { throw new AgentFileValidationError("No files provided"); } if (!Array.isArray(files)) { throw new AgentFileValidationError("Files is malformed - not an array"); } if (files.length === 0) { throw new AgentFileValidationError("Files array is empty"); } for (const file of files) { if (!file.path) throw new AgentFileValidationError(`File does not have a path`); if (!file.content && file.content !== "") throw new AgentFileValidationError(`File ${file.path} has no content`); } if (files.length !== new Set(files).size) { throw new AgentFileValidationError(`Files contains duplicates`); } } export { validateAgentFiles };