Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #69 from mirpedrol/file-validation-error
Browse files Browse the repository at this point in the history
skip file validation if path is an empty string and improve error message
  • Loading branch information
mirpedrol authored Jul 10, 2023
2 parents 62a283e + d23042e commit 1ca9425
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Print param name when path does not exist ([#65](https://github.com/nextflow-io/nf-validation/pull/65))
- Fix file or directory does not exist error not printed when it was the only error in a samplesheet ([#65](https://github.com/nextflow-io/nf-validation/pull/65))
- Do not return parameter in summary if it has no default in the schema and is set to 'false' ([#66](https://github.com/nextflow-io/nf-validation/pull/66))
- Skip the validation of a file if the path is an empty string and improve error message when the path is invalid ([#69](https://github.com/nextflow-io/nf-validation/pull/69))

## Version 0.2.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,19 @@ class SchemaValidator extends PluginExtensionPoint {
def Map properties = (Map) group.value['properties']
for (p in properties) {
def String key = (String) p.key
if (params[key] == null) {
if (params[key] == null || params[key] == '') {
continue
}
def Map property = properties[key] as Map
if (property.containsKey('schema')) {
def String schema_name = getSchemaPath(baseDir, property['schema'].toString())
def Path file_path = Nextflow.file(params[key]) as Path
def Path file_path
try {
file_path = Nextflow.file(params[key]) as Path
} catch (IllegalArgumentException e) {
errors << "* --${key}: The file path '${params[key]}' is invalid. Unable to validate file.".toString()
continue
}
log.debug "Starting validation: '$key': '$file_path' with '$schema_name'"
def String fileType = SamplesheetConverter.getFileType(file_path)
def String delimiter = fileType == "csv" ? "," : fileType == "tsv" ? "\t" : null
Expand Down

0 comments on commit 1ca9425

Please sign in to comment.