Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions src/hooks/useCDLValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,23 @@ interface CDLValidationResult {
}

/**
* Validate CDL code using the proper CDL parser
* Validate CDL code using the proper CDL parser.
* Parses the entire string (supports multi-line definitions and references).
*/
function validateCDL(code: string): CDLValidationResult {
const lines = code.split('\n');
const errors: ValidationError[] = [];
const trimmed = code.trim();
if (!trimmed) return { isValid: true, errors: [] };

lines.forEach((line, lineIndex) => {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) return; // Skip empty lines and comments
const result = parseCDL(trimmed);

const result = parseCDL(trimmed);

if (!result.valid && result.error) {
errors.push({
line: lineIndex + 1,
column: 1,
message: result.error,
});
}
});
if (!result.valid && result.error) {
errors.push({
line: 1,
column: 1,
message: result.error,
});
}

return {
isValid: errors.length === 0,
Expand Down
Loading
Loading