validate method
Validate this input, returning a list of error messages (empty = valid).
Implementation
List<String> validate() {
final errors = <String>[];
if (notebookPath.isEmpty) {
errors.add('Missing required parameter: notebook_path');
} else if (!p.isAbsolute(notebookPath)) {
errors.add('notebook_path must be an absolute path');
} else if (!notebookPath.endsWith('.ipynb')) {
errors.add('File must be a .ipynb notebook');
}
const validCommands = ['add', 'edit', 'delete', 'move'];
if (command.isEmpty) {
errors.add('Missing required parameter: command');
} else if (!validCommands.contains(command)) {
errors.add('command must be one of: ${validCommands.join(", ")}');
}
if ((command == 'add' || command == 'edit') &&
(source == null || source!.isEmpty)) {
errors.add('source/content is required for $command');
}
if (command == 'move' && newIndex == null) {
errors.add('new_index/target_index is required for move');
}
if (cellType != null && !['code', 'markdown', 'raw'].contains(cellType)) {
errors.add('cell_type must be one of: code, markdown, raw');
}
return errors;
}