This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
forked from nextflow-io/nf-schema
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from nvnieuwk/feat/format-filepathpattern
format file-path-pattern
- Loading branch information
Showing
6 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package nextflow.validation | ||
|
||
import java.nio.file.Path | ||
import groovy.util.logging.Slf4j | ||
|
||
import org.everit.json.schema.FormatValidator | ||
import nextflow.Nextflow | ||
|
||
@Slf4j | ||
public class FilePathPatternValidator implements FormatValidator { | ||
|
||
@Override | ||
public Optional<String> validate(final String subject) { | ||
if (subject.startsWith('s3://')) { | ||
log.debug("S3 paths are not supported by 'FilePathPatternValidator': '${subject}'") | ||
return Optional.empty() | ||
} | ||
ArrayList files = Nextflow.file(subject) as ArrayList | ||
ArrayList errors = [] | ||
|
||
if(files.size() == 0) { | ||
return Optional.of("No files were found using the globbing pattern '${subject}'" as String) | ||
} | ||
for( file : files ) { | ||
if (file.isDirectory()) { | ||
errors.add("'${file.toString()}' is not a file, but a directory" as String) | ||
} | ||
} | ||
if(errors.size > 0) { | ||
return Optional.of(errors.join('\n')) | ||
} | ||
return Optional.empty() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters